authtracker 0.0.1__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.
Files changed (64) hide show
  1. authtracker-0.0.1/.github/workflows/release.yml +97 -0
  2. authtracker-0.0.1/.gitignore +44 -0
  3. authtracker-0.0.1/FEATURES.md +91 -0
  4. authtracker-0.0.1/LICENSE +202 -0
  5. authtracker-0.0.1/PKG-INFO +215 -0
  6. authtracker-0.0.1/README.md +173 -0
  7. authtracker-0.0.1/docs/API.md +265 -0
  8. authtracker-0.0.1/docs/CONFIGURATION.md +123 -0
  9. authtracker-0.0.1/docs/DEVELOPMENT.md +175 -0
  10. authtracker-0.0.1/docs/GUIDE.md +718 -0
  11. authtracker-0.0.1/examples/01_quickstart.py +45 -0
  12. authtracker-0.0.1/examples/02_config_and_dataset.py +74 -0
  13. authtracker-0.0.1/examples/03_registry_and_promotion.py +83 -0
  14. authtracker-0.0.1/examples/04_resume_with_checkpoints.py +83 -0
  15. authtracker-0.0.1/examples/05_rules_and_failures.py +64 -0
  16. authtracker-0.0.1/examples/06_code_lineage.py +98 -0
  17. authtracker-0.0.1/examples/07_pytorch_bundle.py +102 -0
  18. authtracker-0.0.1/examples/08_wandb_backend.py +57 -0
  19. authtracker-0.0.1/examples/README.md +49 -0
  20. authtracker-0.0.1/examples/_common.py +44 -0
  21. authtracker-0.0.1/examples/pytorch_bundle/architecture.py +15 -0
  22. authtracker-0.0.1/examples/train.yaml +12 -0
  23. authtracker-0.0.1/pyproject.toml +54 -0
  24. authtracker-0.0.1/src/authtracker/__init__.py +16 -0
  25. authtracker-0.0.1/src/authtracker/backends/__init__.py +95 -0
  26. authtracker-0.0.1/src/authtracker/backends/base.py +136 -0
  27. authtracker-0.0.1/src/authtracker/backends/local.py +200 -0
  28. authtracker-0.0.1/src/authtracker/backends/mlflow_backend.py +310 -0
  29. authtracker-0.0.1/src/authtracker/backends/resilient.py +329 -0
  30. authtracker-0.0.1/src/authtracker/backends/wandb_backend.py +235 -0
  31. authtracker-0.0.1/src/authtracker/bundle.py +887 -0
  32. authtracker-0.0.1/src/authtracker/capture.py +175 -0
  33. authtracker-0.0.1/src/authtracker/cli.py +51 -0
  34. authtracker-0.0.1/src/authtracker/configfile.py +84 -0
  35. authtracker-0.0.1/src/authtracker/dataset.py +98 -0
  36. authtracker-0.0.1/src/authtracker/errors.py +18 -0
  37. authtracker-0.0.1/src/authtracker/registry.py +118 -0
  38. authtracker-0.0.1/src/authtracker/run.py +346 -0
  39. authtracker-0.0.1/src/authtracker/settings.py +171 -0
  40. authtracker-0.0.1/src/authtracker/simple.py +241 -0
  41. authtracker-0.0.1/src/authtracker/testing.py +82 -0
  42. authtracker-0.0.1/src/authtracker/utils.py +321 -0
  43. authtracker-0.0.1/src/authtracker/watch.py +59 -0
  44. authtracker-0.0.1/tests/TESTING.md +57 -0
  45. authtracker-0.0.1/tests/conftest.py +7 -0
  46. authtracker-0.0.1/tests/test_authtracker.py +183 -0
  47. authtracker-0.0.1/tests/test_bundle.py +871 -0
  48. authtracker-0.0.1/tests/test_capture.py +142 -0
  49. authtracker-0.0.1/tests/test_code_snapshot.py +198 -0
  50. authtracker-0.0.1/tests/test_config_dataset.py +202 -0
  51. authtracker-0.0.1/tests/test_container.py +208 -0
  52. authtracker-0.0.1/tests/test_contract.py +158 -0
  53. authtracker-0.0.1/tests/test_examples.py +173 -0
  54. authtracker-0.0.1/tests/test_flavor_detection.py +166 -0
  55. authtracker-0.0.1/tests/test_git_info.py +84 -0
  56. authtracker-0.0.1/tests/test_offline.py +153 -0
  57. authtracker-0.0.1/tests/test_packaging.py +56 -0
  58. authtracker-0.0.1/tests/test_periodic_upload.py +96 -0
  59. authtracker-0.0.1/tests/test_pickle.py +367 -0
  60. authtracker-0.0.1/tests/test_resume.py +322 -0
  61. authtracker-0.0.1/tests/test_simple.py +171 -0
  62. authtracker-0.0.1/tests/test_system_metrics.py +94 -0
  63. authtracker-0.0.1/tests/test_wandb.py +136 -0
  64. authtracker-0.0.1/tests/test_watch.py +81 -0
@@ -0,0 +1,97 @@
1
+ name: Release
2
+
3
+ # On every push to main that changes the package source: test, bump the patch
4
+ # version, tag it, and publish to PyPI. Needs the repository secret PYPI_API_TOKEN.
5
+ on:
6
+ push:
7
+ branches: [main]
8
+ paths:
9
+ - "src/authtracker/**"
10
+ workflow_dispatch:
11
+
12
+ # One release at a time, so two quick merges can't race on the version number.
13
+ concurrency:
14
+ group: release
15
+ cancel-in-progress: false
16
+
17
+ permissions:
18
+ contents: write # push the version bump commit and the tag
19
+
20
+ jobs:
21
+ release:
22
+ # Safety net against loops: never run for the bot's own bump commit.
23
+ if: "!contains(github.event.head_commit.message, '[skip ci]')"
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ with:
28
+ fetch-depth: 0
29
+
30
+ - uses: actions/setup-python@v5
31
+ with:
32
+ python-version: "3.12"
33
+
34
+ - name: Test
35
+ run: |
36
+ python -m pip install --upgrade pip
37
+ pip install -e ".[dev]"
38
+ # CPU-only PyTorch, so the bundle tests run instead of being skipped
39
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
40
+ pytest -q
41
+
42
+ - name: Bump patch version
43
+ id: bump
44
+ run: |
45
+ f=src/authtracker/__init__.py
46
+ cur=$(sed -nE 's/^__version__ = "([0-9]+\.[0-9]+\.[0-9]+)"$/\1/p' "$f")
47
+ [ -n "$cur" ] || { echo "version not found in $f"; exit 1; }
48
+ IFS=. read -r maj min pat <<< "$cur"
49
+ new="$maj.$min.$((pat + 1))"
50
+ if git rev-parse -q --verify "refs/tags/$new" >/dev/null; then
51
+ echo "tag $new already exists"; exit 1
52
+ fi
53
+ sed -i -E "s/^__version__ = \".*\"$/__version__ = \"$new\"/" "$f"
54
+ echo "version=$new" >> "$GITHUB_OUTPUT"
55
+ echo "Bumping $cur -> $new"
56
+
57
+ - name: Build
58
+ run: |
59
+ pip install build twine
60
+ python -m build
61
+ twine check --strict dist/*
62
+
63
+ - name: Commit and tag
64
+ run: |
65
+ v=${{ steps.bump.outputs.version }}
66
+ prev=$(git describe --tags --abbrev=0 2>/dev/null || true)
67
+
68
+ # Release notes = commit subjects since the previous tag (bot commits excluded).
69
+ {
70
+ echo "## What's changed"
71
+ echo
72
+ git log ${prev:+$prev..HEAD} --no-merges --invert-grep --grep='^chore: release' \
73
+ --pretty='- %s (%h)'
74
+ if [ -n "$prev" ]; then
75
+ echo
76
+ echo "**Full changelog:** ${{ github.server_url }}/${{ github.repository }}/compare/$prev...$v"
77
+ fi
78
+ } > RELEASE_NOTES.md
79
+ cat RELEASE_NOTES.md
80
+
81
+ git config user.name "github-actions[bot]"
82
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
83
+ git add src/authtracker/__init__.py
84
+ git commit -m "chore: release $v [skip ci]"
85
+ git tag -a "$v" -m "authtracker $v" -m "$(cat RELEASE_NOTES.md)"
86
+ git push origin HEAD:main "$v"
87
+
88
+ - name: Publish to PyPI
89
+ env:
90
+ TWINE_USERNAME: __token__
91
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
92
+ run: twine upload --skip-existing dist/*
93
+
94
+ - name: Create GitHub release
95
+ env:
96
+ GH_TOKEN: ${{ github.token }}
97
+ run: gh release create "${{ steps.bump.outputs.version }}" dist/* --notes-file RELEASE_NOTES.md --title "${{ steps.bump.outputs.version }}"
@@ -0,0 +1,44 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+
8
+ # Virtual environments
9
+ .venv/
10
+ venv/
11
+ env/
12
+
13
+ # Tool caches
14
+ .pytest_cache/
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+ .tox/
18
+ .coverage
19
+ .coverage.*
20
+ htmlcov/
21
+ .ipynb_checkpoints/
22
+
23
+ # Secrets and credentials (never commit)
24
+ .env
25
+ .env.*
26
+ *.pem
27
+ *.key
28
+ *credentials*.json
29
+
30
+ # Data written by the examples and by tracking tools
31
+ examples/data/
32
+ mlruns/
33
+ mlartifacts/
34
+ wandb/
35
+ *.db
36
+ .authtracker/
37
+
38
+ # Logs and local outputs
39
+ *.log
40
+
41
+ # OS / editor
42
+ .DS_Store
43
+ .idea/
44
+ .vscode/
@@ -0,0 +1,91 @@
1
+ # Features
2
+
3
+ What authtracker does, grouped as major, minor and patch. See the README for usage.
4
+
5
+ ## Major
6
+
7
+ Tracking
8
+ - Three levels: model (an MLflow experiment), experiment (parent run), run (child run).
9
+ - `init`, `start`, `log`, `save`, `finish`. No `with` blocks or run objects needed.
10
+ - Metrics with an automatic step, or your own `step=`.
11
+ - Params, tags, text, files and folders, all through `at.save`.
12
+ - Runs close when the script ends. If it crashes, the run is marked FAILED and the traceback is saved.
13
+ - A `with` API (`authtracker.run`) for explicit scopes.
14
+
15
+ Backends
16
+ - MLflow is the default. W&B is optional (`pip install authtracker[wandb]`). A local JSON backend works with no server.
17
+ - All backends sit behind one small `Backend` class. A feature a backend lacks raises `UnsupportedError`.
18
+ - Add your own backend through the `authtracker.backends` entry point.
19
+
20
+ Reproducibility
21
+ - Git sha, branch, remote (token removed), commit URL and a dirty flag.
22
+ - Uncommitted changes, including new files, saved as `code_changes.patch`.
23
+ - Your training script saved as `script_<name>`.
24
+ - Dataset hash for a file, folder or manifest, plus name and version.
25
+ - Training YAML saved with the run and flattened into params.
26
+ - pip requirements and environment info.
27
+ - Container image, ideally pinned by digest.
28
+
29
+ Models
30
+ - MLflow flavors, with the flavor detected for you.
31
+ - PyTorch bundle: `architecture.py`, `weights.pth`, `inference.py`, `requirements.txt`, `environment.txt` and `bundle.json`. Loads as plain PyTorch, with the weights loaded using `weights_only=True`.
32
+ - Builders (`factory=`), extra files (`assets=`) and extra metadata (`extras=`).
33
+ - A loaded model keeps its code, so you can fine-tune it and save it again.
34
+
35
+ Registry
36
+ - `register`, `promote`, `rollback`, `load` and `best_run`, using aliases.
37
+ - Promotion gates: a minimum metric, beating the current production model, and which aliases are gated.
38
+
39
+ Resume
40
+ - `at.init(..., resume=True)` continues the last matching run, or starts a new one if there is none.
41
+ - `at.start(name, resume=...)` does the same for a run inside the experiment.
42
+ - Steps carry on from the last logged step.
43
+ - `at.restore(name)` downloads a file the run saved earlier (a checkpoint, say) and returns its path, or `None`.
44
+ - Params can be repeated or added on resume, but not changed.
45
+ - Files from earlier parts are kept (`.resume1`, `.resume2`).
46
+
47
+ Outages
48
+ - Failed calls are retried.
49
+ - If the server stays down, operations are queued on disk. `authtracker sync` uploads them later.
50
+ - A down server never stops training.
51
+
52
+ ## Minor
53
+
54
+ - `at.watch(model, every=100)` logs the gradient norm of each layer and the total (`grad_norm/<layer>`, `grad_norm/total`). Numbers only, no histograms. PyTorch 2.1+.
55
+ - Console output (stdout, stderr, logging) saved with the run, uploaded every 60 seconds, capped at 20 MB.
56
+ - System metrics (CPU, memory, GPU) on by default. Switch them off for one run with `at.init(..., system_metrics=False)`, or for a machine with `AUTHTRACKER_SYSTEM_METRICS=false`.
57
+ - A model wrapped in `DataParallel`, `DistributedDataParallel` or `torch.compile` is saved without the wrapper.
58
+ - Pickle flavor, opt-in on save and on load: your own code is bundled, hashes are checked before unpickling, and the save checks it loads in a clean process.
59
+ - Bundling a class defined in a script or notebook.
60
+ - A hint when MLflow's traced-graph save fails because the model is on GPU.
61
+ - Settings from `AUTHTRACKER_*` environment variables. Arguments to `init()` and `save()` always win.
62
+ - Rules for required tags, allowed models and allowed metric names.
63
+ - CLI: `authtracker config`, `doctor` and `sync`.
64
+ - Files that look like secrets are left out of the saved patch and script. `save_code=False` turns code saving off.
65
+ - `authtracker.testing.check_backend` to test a custom backend.
66
+
67
+ ## Patch
68
+
69
+ - Remote URLs are cleaned of tokens before they are stored.
70
+ - An image tag without a digest gives a warning.
71
+ - Image is read from the argument, ECS metadata, GitLab's `CI_JOB_IMAGE` or docker.
72
+ - Errors are specific (`ConfigError`, `ValidationError`, `PromotionError`, `BackendError`, `UnsupportedError`), all under `AuthTrackerError`.
73
+ - A backend that can't resume stops with a message instead of starting fresh.
74
+ - If the server can't be asked about an earlier run, a new run starts with a warning.
75
+ - W&B offline mode works.
76
+ - Needs Python 3.10+. Core dependencies are `pyyaml` and `cloudpickle`.
77
+
78
+ ## Limits
79
+
80
+ - No rank handling for distributed training. With `torchrun` or several nodes, call authtracker from rank 0 only (see "Training on several GPUs" in the README).
81
+
82
+ ## Not tested yet
83
+
84
+ - Any multi-GPU run (`DataParallel`, DDP or several nodes).
85
+
86
+ - A real EC2, S3 or login-protected server.
87
+ - CUDA, Windows and Linux.
88
+ - W&B online mode and registry.
89
+ - How the MLflow UI shows repeated steps.
90
+
91
+ The package is also not published, has no license and has no CI.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.5
2
+ Name: authtracker
3
+ Version: 0.0.1
4
+ Summary: Backend-independent, variable-configured experiment tracking and model versioning on top of MLflow.
5
+ Project-URL: Homepage, https://github.com/phospheneai/authtracker
6
+ Project-URL: Source, https://github.com/phospheneai/authtracker
7
+ Project-URL: Issues, https://github.com/phospheneai/authtracker/issues
8
+ Author: Phosphene AI
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: experiment-tracking,machine-learning,mlflow,mlops,model-registry,wandb
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: cloudpickle<4,>=3
23
+ Requires-Dist: pyyaml<7,>=6
24
+ Provides-Extra: dev
25
+ Requires-Dist: mlflow<4,>=3.0; extra == 'dev'
26
+ Requires-Dist: psutil; extra == 'dev'
27
+ Requires-Dist: pytest>=7; extra == 'dev'
28
+ Requires-Dist: ruff>=0.5; extra == 'dev'
29
+ Requires-Dist: scikit-learn; extra == 'dev'
30
+ Requires-Dist: wandb<1,>=0.19.10; extra == 'dev'
31
+ Provides-Extra: gpu
32
+ Requires-Dist: pynvml; extra == 'gpu'
33
+ Provides-Extra: mlflow
34
+ Requires-Dist: mlflow<4,>=3.0; extra == 'mlflow'
35
+ Requires-Dist: psutil; extra == 'mlflow'
36
+ Provides-Extra: mlflow-skinny
37
+ Requires-Dist: mlflow-skinny<4,>=3.0; extra == 'mlflow-skinny'
38
+ Requires-Dist: psutil; extra == 'mlflow-skinny'
39
+ Provides-Extra: wandb
40
+ Requires-Dist: wandb<1,>=0.19.10; extra == 'wandb'
41
+ Description-Content-Type: text/markdown
42
+
43
+ # authtracker
44
+
45
+ [![PyPI](https://img.shields.io/pypi/v/authtracker)](https://pypi.org/project/authtracker/)
46
+ [![License](https://img.shields.io/pypi/l/authtracker)](https://github.com/phospheneai/authtracker/blob/main/LICENSE)
47
+
48
+ Experiment tracking and model versioning with a handful of calls. The same code runs on **MLflow**
49
+ (the default) or **Weights & Biases**, and you switch with one environment variable. Every run also
50
+ records the code, data and environment that produced it, so you can reproduce it later.
51
+
52
+ Small by design: no server of its own, settings only from environment variables, and other platforms
53
+ plug in as a single class.
54
+
55
+ - [API reference](https://github.com/phospheneai/authtracker/blob/main/docs/API.md)
56
+ - [User guide](https://github.com/phospheneai/authtracker/blob/main/docs/GUIDE.md)
57
+ - [Configuration (environment variables)](https://github.com/phospheneai/authtracker/blob/main/docs/CONFIGURATION.md)
58
+ - [Developer guide](https://github.com/phospheneai/authtracker/blob/main/docs/DEVELOPMENT.md)
59
+ - [Examples](https://github.com/phospheneai/authtracker/blob/main/examples/README.md)
60
+
61
+ ## Quickstart
62
+
63
+ ```
64
+ pip install "authtracker[mlflow]"
65
+ ```
66
+
67
+ ```python
68
+ import authtracker as at
69
+ from sklearn.linear_model import LogisticRegression
70
+
71
+ X, y = [[0], [1], [2], [3]], [0, 0, 1, 1]
72
+
73
+ at.init(model="model1", experiment="demo", dataset_version="v1")
74
+
75
+ for C in (0.1, 1.0, 10.0):
76
+ at.start(f"C{C}", config={"C": C}) # one run per trial
77
+ clf = LogisticRegression(C=C).fit(X, y)
78
+ at.log({"accuracy": clf.score(X, y)})
79
+ at.save(clf) # the model
80
+
81
+ best = at.best_run("model1", "demo", metric="accuracy")
82
+ version = at.register(best)
83
+ at.promote("model1", version, "production")
84
+ print(at.load("model1", "production").predict([[3]]))
85
+ ```
86
+
87
+ With no setup, runs go to a `mlflow.db` file in the current folder. To browse them, run `mlflow ui`.
88
+ To use a server, set `AUTHTRACKER_TRACKING_URI=https://mlflow.example.com` first.
89
+
90
+ ## How it works
91
+
92
+ Every run lives in three levels:
93
+
94
+ ```
95
+ fake-image <- model (an MLflow experiment, a W&B project)
96
+ └── baseline <- experiment (a parent run)
97
+ ├── lr0.01 <- run (a child run: metrics, files, model)
98
+ └── lr0.001
99
+ ```
100
+
101
+ | Call | What it does |
102
+ |---|---|
103
+ | `at.init(model, experiment, ...)` | Opens the experiment. Takes `config="train.yaml"` and `dataset={...}` too. |
104
+ | `at.start(name, config={...})` | Starts a run (one trial) and closes the previous one. |
105
+ | `at.log({...})` | Logs metrics. The step counts up by itself. |
106
+ | `at.save(thing)` | Saves a file, a folder, text (with `name=`) or a model. |
107
+ | `at.best_run(model, experiment, metric)` | The best run by a metric. |
108
+ | `at.register()` / `at.promote(model, version, alias)` / `at.rollback(model)` | Versions and aliases. |
109
+ | `at.load(model, alias)` | Loads a model by alias, never by run id. |
110
+
111
+ Runs close when the script ends, as `FAILED` with the traceback saved if it ended with an error.
112
+ In a notebook, call `at.finish()`.
113
+
114
+ ## Install
115
+
116
+ | Install | Use it for |
117
+ |---|---|
118
+ | `pip install "authtracker[mlflow]"` | MLflow, the default. Can also run a server or a local SQLite store. |
119
+ | `pip install "authtracker[mlflow-skinny]"` | A light client that only sends runs to an existing MLflow server. |
120
+ | `pip install "authtracker[wandb]"` | Weights & Biases. |
121
+ | `pip install "authtracker[gpu]"` | Also chart NVIDIA GPU use. Combine with the ones above. |
122
+
123
+ A plain `pip install authtracker` installs only the core, with no tracking platform, so pick one of the above.
124
+ Needs Python 3.10+. From a checkout, use `pip install -e ".[dev]"`.
125
+
126
+ ## What each run records
127
+
128
+ - **Code:** git commit, branch, remote (a token in it is removed), the uncommitted changes as a patch, and
129
+ your script. Rebuild the exact code of any run from them.
130
+ - **Data:** name, version, size and a fingerprint (hash) of your dataset folder.
131
+ - **Settings:** a training YAML, saved with the run and logged as parameters.
132
+ - **Environment:** package versions, `requirements.txt`, and the container image.
133
+ - **Output:** everything the run prints, saved as `output.log`, plus CPU, memory and GPU charts.
134
+
135
+ ## Models
136
+
137
+ `at.save(model)` detects sklearn, XGBoost, LightGBM, PyTorch and others. For plain PyTorch, save a
138
+ **bundle**: a folder with your architecture file, the weights and a sample inference script. Loading it
139
+ gives you your own class back.
140
+
141
+ ```python
142
+ at.save(net, flavor="bundle", init_args={"hidden": 32})
143
+ net = at.load("model1", "production") # your Classifier, with its weights
144
+ ```
145
+
146
+ ## Choose a backend
147
+
148
+ ```
149
+ export AUTHTRACKER_BACKEND=mlflow # the default
150
+ export AUTHTRACKER_BACKEND=wandb # Weights & Biases
151
+ ```
152
+
153
+ Your training code does not change. On W&B, tracking, files and model artifacts work. The model registry
154
+ (`register`, `promote`, `rollback`, `load`) does not yet and raises a clear error.
155
+
156
+ ## Configuration
157
+
158
+ Everything is an environment variable, so the same code runs anywhere. A few common ones:
159
+
160
+ | Variable | What it does |
161
+ |---|---|
162
+ | `AUTHTRACKER_BACKEND` | `mlflow` (default), `wandb` or `local`. |
163
+ | `AUTHTRACKER_TRACKING_URI` | Your MLflow server or store. |
164
+ | `AUTHTRACKER_REQUIRED_TAGS` | Tags every run must have, for example `owner,dataset_version`. |
165
+ | `AUTHTRACKER_ALLOWED_MODELS` | Allowed model names. |
166
+ | `AUTHTRACKER_PROMOTE_METRIC` / `_MIN` / `_MUST_BEAT_PROD` | Rules that must pass before `production`. |
167
+
168
+ All of them are in the [configuration reference](https://github.com/phospheneai/authtracker/blob/main/docs/CONFIGURATION.md).
169
+
170
+ ```
171
+ authtracker config show # the resolved settings
172
+ authtracker doctor # is the backend reachable?
173
+ authtracker sync # upload operations queued while the server was down
174
+ ```
175
+
176
+ ## Good to know
177
+
178
+ - One run is open at a time per process. For parallel trials, use separate processes.
179
+ - With several GPUs or nodes, call authtracker from the main process (rank 0) only.
180
+ - A tracking outage never stops training. Writes are retried, queued on disk and uploaded later.
181
+ Saving a model, `register`, `load` and `best_run` need the server and raise an error instead.
182
+ - `at.init(..., resume=True)` continues an earlier run. It restores the record, not your model:
183
+ save a checkpoint with `at.save` and get it back with `at.restore`.
184
+ - Models saved as pickles can run code when loaded. Only load models you trust.
185
+
186
+ ## Troubleshooting
187
+
188
+ | You see | Do this |
189
+ |---|---|
190
+ | `Backend 'mlflow' needs MLflow` | Install an extra: `pip install "authtracker[mlflow]"`. |
191
+ | `Unknown model ...` or `Missing required tags` | A rule is set. Check `authtracker config show`. |
192
+ | `BackendError` on `register` or `load` | The server could not be reached. Run `authtracker doctor`. |
193
+ | `... cannot change parameters it already has` | You resumed a run with a different value. Use a new run (`resume=False`). |
194
+ | Runs show in the wrong place | The UI and your script use different stores. Point both at the same `AUTHTRACKER_TRACKING_URI`. |
195
+
196
+ ## Status
197
+
198
+ **Experimental.** Tested with 250+ automated tests and eight runnable examples, on macOS with MLflow
199
+ (SQLite) and W&B in offline mode. Not yet verified: a remote or login-protected MLflow server, W&B online
200
+ mode, NVIDIA GPUs, multi-GPU jobs, and Windows. Expect rough edges and report them as issues.
201
+
202
+ ## Development
203
+
204
+ ```
205
+ pip install -e ".[dev]"
206
+ pytest
207
+ ```
208
+
209
+ See the [developer guide](https://github.com/phospheneai/authtracker/blob/main/docs/DEVELOPMENT.md). Releases are
210
+ automatic: a merge to `main` that changes `src/authtracker/` runs the tests, bumps the version, tags it and
211
+ publishes to PyPI.
212
+
213
+ ## License
214
+
215
+ Apache-2.0. See [LICENSE](https://github.com/phospheneai/authtracker/blob/main/LICENSE).