{"id":21135237,"url":"https://github.com/cloneofsimo/ptar","last_synced_at":"2025-07-09T03:32:48.246Z","repository":{"id":242527282,"uuid":"809666350","full_name":"cloneofsimo/ptar","owner":"cloneofsimo","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-03T13:27:16.000Z","size":7,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-03T15:32:57.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloneofsimo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-03T08:06:18.000Z","updated_at":"2024-06-03T15:33:06.931Z","dependencies_parsed_at":"2024-06-03T15:33:06.392Z","dependency_job_id":"2590041c-ebed-49d2-b31a-71c15d730a8b","html_url":"https://github.com/cloneofsimo/ptar","commit_stats":null,"previous_names":["cloneofsimo/ptar"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fptar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fptar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fptar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fptar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloneofsimo","download_url":"https://codeload.github.com/cloneofsimo/ptar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225482022,"owners_count":17481179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T06:46:50.130Z","updated_at":"2024-11-20T06:46:50.669Z","avatar_url":"https://github.com/cloneofsimo.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ptar: Parallel Tar Reader for Effecient Pytorch DataLoader\n\nTBD\n\n`ptar` is a Python package that provides a parallel tar file reader implemented using C++ and `pybind11`. This package allows efficient reading of multiple tar files containing specific file types in parallel using multiple threads that prefetch data in non-blocking fashion, just like how it is done in PyTorch's `DataLoader`. However, it is done with threads and in c++, that speeds up the process significantly.\n\n# Usage\n\n```python\nfrom ptar import Ptar\n\nshardlist = [f\"shard{i}.tar.gz\" for i in range(5)]\n# tar has 3 files with extensions .txt, .py, .cpp, in order.\n\nschema = ['.txt', '.py', '.cpp']\n\nreader = Ptar(shardlist, schema)\n\nall_data = []\n\nfor i in range(5):\n    data = reader.get_next()\n    print(data)\n    # this will return all 3 of them.\n\n# Make the reader iterate from beginning.\nreader.reset()\n\n# return all 15 of them all at once, as list of lists.\ndata = reader.get_next_n(5)\n```\n\n## Features.\n\n- **Parallel Reading**: Utilizes multiple threads to read from a list of tar files in parallel.\n- **File Type Filtering**: Supports filtering by file extensions (e.g., `.txt`, `.py`, `.cpp`).\n- **Python Interface**: Provides a Python interface for ease of use.\n\n## Installation\n\n### Prerequisites\n\nEnsure you have the following dependencies installed:\n\n- Python 3.9\n- CMake 3.12 or higher\n- `libarchive` development libraries\n- `pybind11`\n\nYou can install the necessary system packages using:\n\n```sh\nsudo apt-get update\nsudo apt-get install python3.9 python3.9-dev cmake libarchive-dev\npip install pybind11 setuptools\n```\n\n### Virtual Environment Setup\n\n1. **Create and activate a virtual environment**:\n\n```sh\npython3 -m venv myenv\nsource myenv/bin/activate\n```\n\n2. **Ensure Python development headers are accessible**:\n\n```sh\nmkdir -p myenv/include/python3.9\nln -s /usr/include/python3.9/* myenv/include/python3.9/\nmkdir -p myenv/lib\nln -s /usr/lib/x86_64-linux-gnu/libpython3.9.so myenv/lib/\n```\n\n### Building and Installing `ptar`\n\n1. **Clone the repository**:\n\n```sh\ngit clone https://github.com/cloneofsimo/ptar.git\ncd ptar\n```\n\n2. **Install the package**:\n\n```sh\npython setup.py install\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2Fptar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloneofsimo%2Fptar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2Fptar/lists"}