barecat 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- barecat-0.2.5/.github/workflows/python-publish.yml +35 -0
- barecat-0.2.5/.gitignore +162 -0
- barecat-0.2.5/.readthedocs.yaml +13 -0
- barecat-0.2.5/LICENSE +21 -0
- barecat-0.2.5/MANIFEST.in +1 -0
- barecat-0.2.5/PKG-INFO +181 -0
- barecat-0.2.5/README.md +128 -0
- barecat-0.2.5/docs/Makefile +20 -0
- barecat-0.2.5/docs/_static/styles/my_theme.css +76 -0
- barecat-0.2.5/docs/_templates/autoapi/index.rst +11 -0
- barecat-0.2.5/docs/_templates/autoapi/python/attribute.rst +1 -0
- barecat-0.2.5/docs/_templates/autoapi/python/class.rst +150 -0
- barecat-0.2.5/docs/_templates/autoapi/python/data.rst +42 -0
- barecat-0.2.5/docs/_templates/autoapi/python/exception.rst +1 -0
- barecat-0.2.5/docs/_templates/autoapi/python/function.rst +25 -0
- barecat-0.2.5/docs/_templates/autoapi/python/method.rst +25 -0
- barecat-0.2.5/docs/_templates/autoapi/python/module.rst +160 -0
- barecat-0.2.5/docs/_templates/autoapi/python/package.rst +1 -0
- barecat-0.2.5/docs/_templates/autoapi/python/property.rst +25 -0
- barecat-0.2.5/docs/_templates/copyright.html +12 -0
- barecat-0.2.5/docs/abbrev_long.bib +207 -0
- barecat-0.2.5/docs/conf.py +208 -0
- barecat-0.2.5/docs/index.rst +141 -0
- barecat-0.2.5/docs/make.bat +35 -0
- barecat-0.2.5/docs/references.bib +0 -0
- barecat-0.2.5/figure.png +0 -0
- barecat-0.2.5/pyproject.toml +94 -0
- barecat-0.2.5/setup.cfg +4 -0
- barecat-0.2.5/setup.py +25 -0
- barecat-0.2.5/src/barecat/__init__.py +87 -0
- barecat-0.2.5/src/barecat/_version.py +21 -0
- barecat-0.2.5/src/barecat/archive_formats.py +196 -0
- barecat-0.2.5/src/barecat/cli.py +260 -0
- barecat-0.2.5/src/barecat/cli_impl.py +269 -0
- barecat-0.2.5/src/barecat/codecs.py +58 -0
- barecat-0.2.5/src/barecat/common.py +440 -0
- barecat-0.2.5/src/barecat/consumed_threadpool.py +117 -0
- barecat-0.2.5/src/barecat/core/__init__.py +0 -0
- barecat-0.2.5/src/barecat/core/barecat.py +1183 -0
- barecat-0.2.5/src/barecat/core/index.py +1794 -0
- barecat-0.2.5/src/barecat/core/sharder.py +299 -0
- barecat-0.2.5/src/barecat/cython/__init__.py +1 -0
- barecat-0.2.5/src/barecat/cython/barecat.c +126 -0
- barecat-0.2.5/src/barecat/cython/barecat.h +15 -0
- barecat-0.2.5/src/barecat/cython/barecat_cython.pyx +211 -0
- barecat-0.2.5/src/barecat/cython/barecat_mmap.c +136 -0
- barecat-0.2.5/src/barecat/cython/barecat_mmap.h +19 -0
- barecat-0.2.5/src/barecat/cython/crc32c.c +238 -0
- barecat-0.2.5/src/barecat/cython/crc32c.h +709 -0
- barecat-0.2.5/src/barecat/defrag.py +206 -0
- barecat-0.2.5/src/barecat/exceptions.py +79 -0
- barecat-0.2.5/src/barecat/from_tar_stream.py +53 -0
- barecat-0.2.5/src/barecat/glob_to_regex.py +138 -0
- barecat-0.2.5/src/barecat/progbar.py +37 -0
- barecat-0.2.5/src/barecat/sql/schema.sql +217 -0
- barecat-0.2.5/src/barecat/threadsafe.py +25 -0
- barecat-0.2.5/src/barecat/to_tar_stream.py +54 -0
- barecat-0.2.5/src/barecat/upgrade_database.py +114 -0
- barecat-0.2.5/src/barecat/upgrade_database2.py +74 -0
- barecat-0.2.5/src/barecat/util.py +297 -0
- barecat-0.2.5/src/barecat/viewerqt6.py +465 -0
- barecat-0.2.5/src/barecat.egg-info/PKG-INFO +181 -0
- barecat-0.2.5/src/barecat.egg-info/SOURCES.txt +67 -0
- barecat-0.2.5/src/barecat.egg-info/dependency_links.txt +1 -0
- barecat-0.2.5/src/barecat.egg-info/entry_points.txt +15 -0
- barecat-0.2.5/src/barecat.egg-info/requires.txt +3 -0
- barecat-0.2.5/src/barecat.egg-info/top_level.txt +1 -0
- barecat-0.2.5/tests/test_barecat.py +73 -0
- barecat-0.2.5/tests/test_cli.py +178 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Upload Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
pypi-publish:
|
|
12
|
+
name: Upload release to PyPI
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
environment: pypi
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write
|
|
17
|
+
steps:
|
|
18
|
+
- name: Check out repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
|
|
23
|
+
- name: Set up Python
|
|
24
|
+
uses: actions/setup-python@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.x"
|
|
27
|
+
|
|
28
|
+
- name: Install build dependencies
|
|
29
|
+
run: python -m pip install --upgrade build
|
|
30
|
+
|
|
31
|
+
- name: Build package distribution
|
|
32
|
+
run: python -m build --sdist
|
|
33
|
+
|
|
34
|
+
- name: Publish package distributions to PyPI
|
|
35
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
barecat-0.2.5/.gitignore
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
*_cython.c
|
|
156
|
+
|
|
157
|
+
# PyCharm
|
|
158
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
159
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
160
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
161
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
162
|
+
#.idea/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
|
|
3
|
+
build:
|
|
4
|
+
os: ubuntu-24.04
|
|
5
|
+
tools:
|
|
6
|
+
python: "3.10"
|
|
7
|
+
commands:
|
|
8
|
+
- python -m pip install .
|
|
9
|
+
- python -m pip install --no-cache-dir -r docs/requirements.txt
|
|
10
|
+
- python -m sphinx -E -b html docs $READTHEDOCS_OUTPUT/html
|
|
11
|
+
|
|
12
|
+
sphinx:
|
|
13
|
+
configuration: docs/conf.py
|
barecat-0.2.5/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 István Sárándi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include src/barecat/sql/*.sql
|
barecat-0.2.5/PKG-INFO
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: barecat
|
|
3
|
+
Version: 0.2.5
|
|
4
|
+
Summary: Scalable archive format for storing millions of small files with random access and SQLite indexing.
|
|
5
|
+
Author-email: István Sárándi <istvan.sarandi@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2023 István Sárándi
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/isarandi/barecat
|
|
29
|
+
Project-URL: Documentation, https://istvansarandi.com/docs/barecat/api/barecat/Barecat.html
|
|
30
|
+
Project-URL: Repository, https://github.com/isarandi/barecat
|
|
31
|
+
Project-URL: Issues, https://github.com/isarandi/barecat/issues
|
|
32
|
+
Project-URL: Author, https://istvansarandi.com
|
|
33
|
+
Keywords: sqlite,dataset,storage,archive,random-access,image-dataset,filesystem,key-value-store,deep-learning,data-loader,file-indexing
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: Intended Audience :: Science/Research
|
|
37
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
38
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
39
|
+
Classifier: Topic :: System :: Archiving
|
|
40
|
+
Classifier: Topic :: System :: Filesystems
|
|
41
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
42
|
+
Classifier: Programming Language :: Python
|
|
43
|
+
Classifier: Programming Language :: Python :: 3
|
|
44
|
+
Classifier: Programming Language :: Cython
|
|
45
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
46
|
+
Requires-Python: >=3.9
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
License-File: LICENSE
|
|
49
|
+
Requires-Dist: multiprocessing-utils
|
|
50
|
+
Requires-Dist: tqdm
|
|
51
|
+
Requires-Dist: crc32c
|
|
52
|
+
Dynamic: license-file
|
|
53
|
+
|
|
54
|
+
# Barecat
|
|
55
|
+
|
|
56
|
+
**[Full API Reference Docs](https://istvansarandi.com/docs/barecat/api/barecat/Barecat.html)**
|
|
57
|
+
|
|
58
|
+
Barecat (**bare** con**cat**enation) is a highly scalable, simple aggregate storage format for
|
|
59
|
+
storing many (tens of millions and more) small files, with focus on fast random access and
|
|
60
|
+
minimal overhead.
|
|
61
|
+
|
|
62
|
+
Barecat can be thought of as a simple filesystem, or as something akin to an indexed tarball, or a
|
|
63
|
+
key-value store. Indeed, it can be [mounted via FUSE](https://github.com/isarandi/barecat-mount), converted to a tarball, or used like a dictionary
|
|
64
|
+
within Python.
|
|
65
|
+
|
|
66
|
+
Barecat associates strings (file paths) with binary data (file contents). It's like a dictionary,
|
|
67
|
+
but it has some special handling for '/' characters in the keys, supporting a filesystem-like
|
|
68
|
+
experience (`listdir`, `walk`, `glob`, etc).
|
|
69
|
+
|
|
70
|
+
Internally, all the data is simply concatenated one after another into one or more data shard files.
|
|
71
|
+
Additionally, an index is maintained in an SQLite database, which stores the shard number, the offset
|
|
72
|
+
and the size of each inner file (as well as a checksum, and further filesystem-like metadata
|
|
73
|
+
like modification time). Barecat also maintains aggregate statistics for each directory, such as the
|
|
74
|
+
total number of files and total file size.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
79
|
+
As you can see, the Barecat format is very simple. Readers/writers are easy to write in any language, since
|
|
80
|
+
SQLite is a widely-supported format.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Background
|
|
84
|
+
|
|
85
|
+
A typical use case for Barecat is storing image files for training deep learning models, where the
|
|
86
|
+
files are accessed randomly during training. The files are typically stored on a network file
|
|
87
|
+
system, where accessing many small files can be slow, and clusters often put a limit on the number
|
|
88
|
+
of files of a user. So it is necessary to somehow merge the small files into big ones.
|
|
89
|
+
However, typical archive formats such as tar are not suitable, since they don't allow fast random
|
|
90
|
+
lookups. In tar, one has to scan the entire archive as there is no central directory.
|
|
91
|
+
Zip is better, but still requires scanning the central directory, which can be slow for very large
|
|
92
|
+
archives with millions or tens of millions of files.
|
|
93
|
+
|
|
94
|
+
We need an index into the archive, and the index itself cannot be required to be loaded
|
|
95
|
+
into memory, to support very large datasets.
|
|
96
|
+
|
|
97
|
+
Therefore, in this format the metadata is indexed separately in an SQLite database for fast lookup
|
|
98
|
+
based on paths. The index also allows fast listing of directory contents and contains aggregate
|
|
99
|
+
statistics (total file size, number of files) for each directory.
|
|
100
|
+
|
|
101
|
+
## Features
|
|
102
|
+
|
|
103
|
+
- **Fast random access**: The archive can be accessed randomly, addressed by filepath,
|
|
104
|
+
without having to scan the entire archive or all the metadata.
|
|
105
|
+
The index is stored in a separate SQLite database file, which itself does not need to be loaded
|
|
106
|
+
entirely into memory. Ideal for storing training image data for deep learning jobs.
|
|
107
|
+
- **Sharding**: To make it easier to move the data around or to distribute it across multiple
|
|
108
|
+
storage devices, the archive can be split into multiple files of equal size (shards, or volumes).
|
|
109
|
+
The shards do not have to be concatenated to be used, the library will keep all shard files open
|
|
110
|
+
and load data from the appropriate one during normal operations.
|
|
111
|
+
- **Fast browsing**: The SQLite database contains an index for the parent directories, allowing
|
|
112
|
+
fast listing of directory contents and aggregate statistics (total file size, number of files).
|
|
113
|
+
- **Intuitive API**: Familiar filesystem-like API, as well as a dictionary-like one.
|
|
114
|
+
- **Mountable**: The archive can be efficiently mounted in readonly or read-write mode.
|
|
115
|
+
- **Simple storage format**: The files are simply concatenated after each other and the index contains
|
|
116
|
+
the offsets and sizes of each file. There is no header format to understand. The index can be
|
|
117
|
+
dumped into any format with simple SQL queries.
|
|
118
|
+
|
|
119
|
+
## Command line interface
|
|
120
|
+
|
|
121
|
+
To create a Barecat archive, use the `barecat-create` or `barecat-create-recursive` commands, which
|
|
122
|
+
are automatically installed executables with the pip package.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
barecat-create --file=mydata.barecat --shard-size=100G < path_of_paths.txt
|
|
126
|
+
|
|
127
|
+
find dirname -name '*.jpg' -print0 | barecat-create --null --file=mydata.barecat --shard-size=100G
|
|
128
|
+
|
|
129
|
+
barecat-create-recursive dir1 dir2 dir3 --file=mydata.barecat --shard-size=100G
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This may yield the following files:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
mydata.barecat-shard-00001
|
|
136
|
+
mydata.barecat-shard-00002
|
|
137
|
+
mydata.barecat-sqlite-index
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The files can be extracted out again. Unix-like permissions, modification times, owner info are
|
|
141
|
+
preserved.
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
barecat-extract --file=mydata.barecat --target-directory=targetdir/
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Python API
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
|
|
151
|
+
import barecat
|
|
152
|
+
|
|
153
|
+
with barecat.Barecat('mydata.barecat', readonly=False) as bc:
|
|
154
|
+
bc['path/to/file/as/stored.jpg'] = binary_file_data
|
|
155
|
+
bc.add_by_path('path/to/file/on/disk.jpg')
|
|
156
|
+
|
|
157
|
+
with open('path', 'rb') as f:
|
|
158
|
+
bc.add('path/to/file/on/disk.jpg', fileobj=f)
|
|
159
|
+
|
|
160
|
+
with barecat.Barecat('mydata.barecat') as bc:
|
|
161
|
+
binary_file_data = bc['path/to/file.jpg']
|
|
162
|
+
entrynames = bc.listdir('path/to')
|
|
163
|
+
for root, dirs, files in bc.walk('path/to/something'):
|
|
164
|
+
print(root, dirs, files)
|
|
165
|
+
|
|
166
|
+
paths = bc.glob('path/to/**/*.jpg', recursive=True)
|
|
167
|
+
|
|
168
|
+
with bc.open('path/to/file.jpg', 'rb') as f:
|
|
169
|
+
data = f.read(123)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Image viewer
|
|
173
|
+
|
|
174
|
+
Barecat comes with a simple image viewer that can be used to browse the contents of a Barecat
|
|
175
|
+
archive.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
barecat-image-viewer mydata.barecat
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
|
barecat-0.2.5/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Barecat
|
|
2
|
+
|
|
3
|
+
**[Full API Reference Docs](https://istvansarandi.com/docs/barecat/api/barecat/Barecat.html)**
|
|
4
|
+
|
|
5
|
+
Barecat (**bare** con**cat**enation) is a highly scalable, simple aggregate storage format for
|
|
6
|
+
storing many (tens of millions and more) small files, with focus on fast random access and
|
|
7
|
+
minimal overhead.
|
|
8
|
+
|
|
9
|
+
Barecat can be thought of as a simple filesystem, or as something akin to an indexed tarball, or a
|
|
10
|
+
key-value store. Indeed, it can be [mounted via FUSE](https://github.com/isarandi/barecat-mount), converted to a tarball, or used like a dictionary
|
|
11
|
+
within Python.
|
|
12
|
+
|
|
13
|
+
Barecat associates strings (file paths) with binary data (file contents). It's like a dictionary,
|
|
14
|
+
but it has some special handling for '/' characters in the keys, supporting a filesystem-like
|
|
15
|
+
experience (`listdir`, `walk`, `glob`, etc).
|
|
16
|
+
|
|
17
|
+
Internally, all the data is simply concatenated one after another into one or more data shard files.
|
|
18
|
+
Additionally, an index is maintained in an SQLite database, which stores the shard number, the offset
|
|
19
|
+
and the size of each inner file (as well as a checksum, and further filesystem-like metadata
|
|
20
|
+
like modification time). Barecat also maintains aggregate statistics for each directory, such as the
|
|
21
|
+
total number of files and total file size.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
As you can see, the Barecat format is very simple. Readers/writers are easy to write in any language, since
|
|
27
|
+
SQLite is a widely-supported format.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Background
|
|
31
|
+
|
|
32
|
+
A typical use case for Barecat is storing image files for training deep learning models, where the
|
|
33
|
+
files are accessed randomly during training. The files are typically stored on a network file
|
|
34
|
+
system, where accessing many small files can be slow, and clusters often put a limit on the number
|
|
35
|
+
of files of a user. So it is necessary to somehow merge the small files into big ones.
|
|
36
|
+
However, typical archive formats such as tar are not suitable, since they don't allow fast random
|
|
37
|
+
lookups. In tar, one has to scan the entire archive as there is no central directory.
|
|
38
|
+
Zip is better, but still requires scanning the central directory, which can be slow for very large
|
|
39
|
+
archives with millions or tens of millions of files.
|
|
40
|
+
|
|
41
|
+
We need an index into the archive, and the index itself cannot be required to be loaded
|
|
42
|
+
into memory, to support very large datasets.
|
|
43
|
+
|
|
44
|
+
Therefore, in this format the metadata is indexed separately in an SQLite database for fast lookup
|
|
45
|
+
based on paths. The index also allows fast listing of directory contents and contains aggregate
|
|
46
|
+
statistics (total file size, number of files) for each directory.
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Fast random access**: The archive can be accessed randomly, addressed by filepath,
|
|
51
|
+
without having to scan the entire archive or all the metadata.
|
|
52
|
+
The index is stored in a separate SQLite database file, which itself does not need to be loaded
|
|
53
|
+
entirely into memory. Ideal for storing training image data for deep learning jobs.
|
|
54
|
+
- **Sharding**: To make it easier to move the data around or to distribute it across multiple
|
|
55
|
+
storage devices, the archive can be split into multiple files of equal size (shards, or volumes).
|
|
56
|
+
The shards do not have to be concatenated to be used, the library will keep all shard files open
|
|
57
|
+
and load data from the appropriate one during normal operations.
|
|
58
|
+
- **Fast browsing**: The SQLite database contains an index for the parent directories, allowing
|
|
59
|
+
fast listing of directory contents and aggregate statistics (total file size, number of files).
|
|
60
|
+
- **Intuitive API**: Familiar filesystem-like API, as well as a dictionary-like one.
|
|
61
|
+
- **Mountable**: The archive can be efficiently mounted in readonly or read-write mode.
|
|
62
|
+
- **Simple storage format**: The files are simply concatenated after each other and the index contains
|
|
63
|
+
the offsets and sizes of each file. There is no header format to understand. The index can be
|
|
64
|
+
dumped into any format with simple SQL queries.
|
|
65
|
+
|
|
66
|
+
## Command line interface
|
|
67
|
+
|
|
68
|
+
To create a Barecat archive, use the `barecat-create` or `barecat-create-recursive` commands, which
|
|
69
|
+
are automatically installed executables with the pip package.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
barecat-create --file=mydata.barecat --shard-size=100G < path_of_paths.txt
|
|
73
|
+
|
|
74
|
+
find dirname -name '*.jpg' -print0 | barecat-create --null --file=mydata.barecat --shard-size=100G
|
|
75
|
+
|
|
76
|
+
barecat-create-recursive dir1 dir2 dir3 --file=mydata.barecat --shard-size=100G
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This may yield the following files:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
mydata.barecat-shard-00001
|
|
83
|
+
mydata.barecat-shard-00002
|
|
84
|
+
mydata.barecat-sqlite-index
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The files can be extracted out again. Unix-like permissions, modification times, owner info are
|
|
88
|
+
preserved.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
barecat-extract --file=mydata.barecat --target-directory=targetdir/
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Python API
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
|
|
98
|
+
import barecat
|
|
99
|
+
|
|
100
|
+
with barecat.Barecat('mydata.barecat', readonly=False) as bc:
|
|
101
|
+
bc['path/to/file/as/stored.jpg'] = binary_file_data
|
|
102
|
+
bc.add_by_path('path/to/file/on/disk.jpg')
|
|
103
|
+
|
|
104
|
+
with open('path', 'rb') as f:
|
|
105
|
+
bc.add('path/to/file/on/disk.jpg', fileobj=f)
|
|
106
|
+
|
|
107
|
+
with barecat.Barecat('mydata.barecat') as bc:
|
|
108
|
+
binary_file_data = bc['path/to/file.jpg']
|
|
109
|
+
entrynames = bc.listdir('path/to')
|
|
110
|
+
for root, dirs, files in bc.walk('path/to/something'):
|
|
111
|
+
print(root, dirs, files)
|
|
112
|
+
|
|
113
|
+
paths = bc.glob('path/to/**/*.jpg', recursive=True)
|
|
114
|
+
|
|
115
|
+
with bc.open('path/to/file.jpg', 'rb') as f:
|
|
116
|
+
data = f.read(123)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Image viewer
|
|
120
|
+
|
|
121
|
+
Barecat comes with a simple image viewer that can be used to browse the contents of a Barecat
|
|
122
|
+
archive.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
barecat-image-viewer mydata.barecat
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = .
|
|
9
|
+
BUILDDIR = _build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
@import url("theme.css");
|
|
2
|
+
@import url("https://fonts.googleapis.com/css2?family=Mona+Sans:ital,wght@0,200..900;1,200..900&family=Geist:wght@100..900&&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Outfit:wght@100..900&display=swap");
|
|
3
|
+
|
|
4
|
+
/*@media (min-width: 960px) {
|
|
5
|
+
.bd-page-width {
|
|
6
|
+
max-width: 120rem;
|
|
7
|
+
}
|
|
8
|
+
}*/
|
|
9
|
+
|
|
10
|
+
#rtd-footer-container {
|
|
11
|
+
margin-top: 0 !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
html[data-theme="light"] {
|
|
15
|
+
--pst-color-table-row-hover-bg: #dfc6ff;
|
|
16
|
+
--pst-color-link-hover: #845818;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
html[data-theme="dark"] {
|
|
20
|
+
--pst-color-table-row-hover-bg: #41296c;
|
|
21
|
+
--pst-color-inline-code: #dd8cd4;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
html[data-theme="dark"] dt:target {
|
|
26
|
+
background-color: #4f4500;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
html[data-theme="dark"] .linkcode-link {
|
|
30
|
+
color: #9090ff;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
html[data-theme="dark"] table.indextable tr.cap {
|
|
34
|
+
background-color: #464646;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
html[data-theme="dark"] a:visited {
|
|
38
|
+
color: #9E67D0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.navbar-brand .logo__title {
|
|
42
|
+
font-family: "Mona Sans", sans-serif;
|
|
43
|
+
font-size: 2.5rem;
|
|
44
|
+
font-weight: 400;
|
|
45
|
+
font-style: normal;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:root {
|
|
49
|
+
--pst-font-family-monospace: "JetBrains Mono", monospace;
|
|
50
|
+
--pst-font-family-heading: "Mona Sans", sans-serif;
|
|
51
|
+
--pst-font-family-base: "Mona Sans", sans-serif;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
body {
|
|
55
|
+
font-weight: 450;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.bd-main .bd-content .bd-article-container {
|
|
59
|
+
max-width: 100%; /* default is 60em */
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/*.bd-sidebar-primary {
|
|
63
|
+
max-width: 20%;
|
|
64
|
+
}*/
|
|
65
|
+
|
|
66
|
+
/* Ensure links in code blocks are underlined */
|
|
67
|
+
.highlight a {
|
|
68
|
+
text-decoration: underline;
|
|
69
|
+
color: #394198; /* Adjust color as needed */
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* For additional emphasis, change hover effect */
|
|
73
|
+
.highlight a:hover {
|
|
74
|
+
text-decoration: underline;
|
|
75
|
+
color: #9090ff;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% extends "python/data.rst" %}
|