flexilims 26.12.0__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.
@@ -0,0 +1,31 @@
1
+ name: Python uv CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths-ignore:
8
+ - "**/*.md"
9
+ - "docs/**"
10
+ - ".gitignore"
11
+ - "LICENSE"
12
+ pull_request:
13
+ paths-ignore:
14
+ - "**/*.md"
15
+ - "docs/**"
16
+ - ".gitignore"
17
+ - "LICENSE"
18
+
19
+ permissions:
20
+ contents: read
21
+
22
+ jobs:
23
+ python-uv-ci:
24
+ uses: znamlab/python-uv-ci/.github/workflows/python-uv-ci.yml@v26.7.1
25
+ permissions:
26
+ contents: read
27
+ pull-requests: write
28
+ with:
29
+ run_tests: true
30
+ run_lint: true
31
+ type_checker: ty
@@ -0,0 +1,28 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions: {}
8
+
9
+ jobs:
10
+ build:
11
+ permissions:
12
+ contents: read
13
+ uses: znamlab/pypi-publish/.github/workflows/build-python-package.yml@v26.12.0
14
+
15
+ publish:
16
+ needs: build
17
+ runs-on: ubuntu-latest
18
+ environment: pypi
19
+ permissions:
20
+ id-token: write
21
+ steps:
22
+ - name: Download distributions
23
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
24
+ with:
25
+ name: python-distributions
26
+ path: dist/
27
+ - name: Publish to PyPI
28
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
@@ -0,0 +1,138 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ .idea/
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # password file
8
+ flexilims/secret_password.py
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ pip-wheel-metadata/
28
+ share/python-wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .nox/
48
+ .coverage
49
+ .coverage.*
50
+ .cache
51
+ nosetests.xml
52
+ coverage.xml
53
+ *.cover
54
+ *.py,cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
99
+ __pypackages__/
100
+
101
+ # Celery stuff
102
+ celerybeat-schedule
103
+ celerybeat.pid
104
+
105
+ # SageMath parsed files
106
+ *.sage.py
107
+
108
+ # Environments
109
+ .env
110
+ .venv
111
+ env/
112
+ venv/
113
+ ENV/
114
+ env.bak/
115
+ venv.bak/
116
+
117
+ # Spyder project settings
118
+ .spyderproject
119
+ .spyproject
120
+
121
+ # Rope project settings
122
+ .ropeproject
123
+
124
+ # mkdocs documentation
125
+ /site
126
+
127
+ # mypy
128
+ .mypy_cache/
129
+ .dmypy.json
130
+ dmypy.json
131
+
132
+ # Ruff
133
+ .ruff_cache/
134
+
135
+ # Pyre type checker
136
+ .pyre/
137
+ .DS_Store
138
+ .vscode
@@ -0,0 +1,12 @@
1
+ # Agent Guidelines
2
+
3
+ ## Changelog
4
+ - Update `CHANGELOG.md` under `# Unreleased` whenever making changes that are important enough to mention to users or maintainers (bugfixes, new features, API or behavior changes, deprecations, significant performance/CI/test changes).
5
+ - Skip changelog entries for trivial internal refactors, typo-only edits, or temporary WIP changes.
6
+
7
+ ## Git
8
+ - Never run `git commit` autonomously. Always present the changes (or stage them if requested) and wait for explicit human confirmation before committing.
9
+
10
+ ## Development Checks
11
+ - Run `uv run ruff check`, `uv run ruff format --check`, `uv run ty check`, and `uv run pytest` before committing. (Integration tests marked `integration` are skipped by default; pass `--run-integration` on the Crick network with `flexiznam` configured to run them.)
12
+ - Note that `pyproject.toml` sets `filterwarnings = ["error"]`, so unexpected warnings will fail tests.
@@ -0,0 +1,151 @@
1
+ # Unreleased
2
+
3
+ Breaking changes:
4
+ - `Flexilims.update_many()` now raises `TypeError` by default if passed non-`str` arguments (since the `update-many` endpoint only stores and matches string values; pass `allow_non_str=True` to bypass this check) and raises `ValueError` when `update_value=""` (rejected by the server; use `update_one()` instead).
5
+
6
+ Bugfixes:
7
+ - Handle missing or `None` `"attributes"` in `OfflineFlexilims.get()`, `OfflineFlexilims.update_one()`, and `format_results()`, and avoid calling `len()` on iterables without `__len__` in `_replace_nones()`.
8
+ - Deduplicate `types` in `download_database()`, preventing redundant queries and crashes in `_add_recursively()` when duplicate types are passed.
9
+ - Make `parse_error()` decode non-UTF-8 bytes with `errors="replace"` instead of raising `UnicodeDecodeError`, and include a truncated server message/body in `Flexilims.handle_error()` for unexpected error status codes (e.g., 5xx).
10
+ - Tighten `Flexilims.project_id` validation to require an exact 24-character hexadecimal string (`[0-9a-fA-F]{24}`), rejecting 24-character strings with spaces, signs, underscores, or `0x` prefixes that `int(..., 16)` previously accepted.
11
+ - Validate `mode` before executing the HTTP request in `Flexilims.safe_execute()`, avoiding running a potentially mutating request before raising `ValueError`.
12
+ - Restore the `parse_error` fallback: a HTTP 400 reply that is not the expected HTML error page raises an `IOError` carrying the raw server message again, instead of a `ValueError` that hid it (and escaped callers catching `OSError`, such as flexiznam).
13
+
14
+ Changes:
15
+ - Update `check_flexilims_validity` to enforce only the MongoDB/BSON field-name rules accepted by the server: reject dict keys containing `.` or starting with `$` recursively at **all** nesting levels (including nested dicts, which previously went unchecked client-side and could be stored in `OfflineFlexilims`), while allowing other characters such as `-`, `/`, and `'`. Values and entity names are unaffected. `SPECIAL_CHARACTERS` remains exported in `flexilims.utils` for backwards compatibility.
16
+ - Remove the obsolete whitespace `UserWarning` from `check_flexilims_validity` (attribute names containing spaces are supported by both the FlexiLIMS API and Web UI).
17
+
18
+ Minor:
19
+ - Fix the `ptest` typo (should be `pytest`) in the uv `dev` dependency group, add `numpy` to it, remove the outdated `dev` optional-dependency extra, and make tox install the `dev` dependency group instead.
20
+ - Run ruff and ty pre-commit hooks from the project's uv environment (replacing the pinned ruff-pre-commit and mypy hooks); bump ruff to 0.17.6 and ty to 0.0.112, and add pre-commit to the uv `dev` group.
21
+ - Offline duplicate-name errors (`post` and renaming via `update_one`) now raise `NameNotUniqueError`, a subclass of both `FlexilimsError` and `IOError`, with a message matching the online API (`... already exist in the project ...`), so callers such as flexiznam handle name conflicts the same way online and offline.
22
+
23
+ # v26.11.0
24
+
25
+ Features:
26
+ - Support deleting direct children by type and origin name in `Flexilims.delete()` via
27
+ `delete(datatype=..., origin_name=..., project_id=...)` (non-recursive).
28
+ - Add `offset` pagination parameter to `Flexilims.get()` and `OfflineFlexilims.get()`,
29
+ and switch `download_database()` to paginate with `offset` + `limit=1000` instead of
30
+ `date_created`.
31
+ - Add `limit`, `cross_project_entity`, and multi-attribute `query_key`/`query_value`
32
+ support to `OfflineFlexilims.get()` for parity with online `Flexilims.get()`.
33
+ - Add configurable request timeouts (`timeout=60` by default) to `Flexilims` and
34
+ `get_token` so stalled requests no longer hang indefinitely.
35
+
36
+ Breaking changes & deprecations:
37
+ - Remove the server-rejected `other_relations` parameter from `post()` (online and
38
+ offline).
39
+ - Deprecate the unused `project_id` parameter in `update_one()` (emits
40
+ `DeprecationWarning` if passed).
41
+
42
+ Bugfixes:
43
+ - Fix attribute validation in `check_flexilims_validity`: use regex whitespace matching,
44
+ return a cleaned deep copy instead of mutating caller dicts in place, replace `NaN`
45
+ inside lists in `_cleanlist`, and validate `attributes` in `update_one` and `update_key`
46
+ in `update_many`.
47
+ - Stop mutating caller dicts in place in `format_results`.
48
+ - Fail immediately on HTTP 401/403 credential errors in `get_token` instead of retrying
49
+ for 10 minutes in `update_token`, use wall-clock deadlines in `update_token`, and
50
+ refresh expired tokens on both 401 and 403.
51
+ - Return non-200 2xx responses from `safe_execute` as warned, report the actual request
52
+ URL on 404, pass `strict_validation` via `params` in `post()` and `update_many()`, and
53
+ make `parse_error` handle multiline HTML error pages.
54
+ - Fix `OfflineFlexilims` data integrity and return types: enforce name uniqueness and
55
+ validate `origin_id` in `post`, raise `FlexilimsError` on unknown `id` in `update_one`
56
+ and `get_children`, re-key renamed entities safely, forward `allow_nulls`/`allow_strings`
57
+ to nested dicts, filter `get()` directly in Python (returning deep-copied `list[dict]`
58
+ with `origin_id=None` for root entities), and set `"origin_id": None` on posted roots.
59
+ - Deduplicate paginated results in `download_database`, keep root `origin_id` as `None`,
60
+ guard against infinite pagination loops, and log a warning when orphaned entities (and
61
+ their descendants) are omitted.
62
+
63
+ Tests & Tooling:
64
+ - Add network-free unit tests in `tests/test_unit.py` and expanded offline/live
65
+ regression tests in `tests/test_offline.py`, `tests/test_main_client.py`, and
66
+ `tests/test_flexilims.py`.
67
+ - Add `AGENTS.md` with changelog, git confirmation, and development check guidelines.
68
+
69
+ # v1.3
70
+
71
+ Performance:
72
+ - Cache `OfflineFlexilims` to increase performance. `get`, `get_children`, and other
73
+ entity lookups add to rebuild and deep-copy the whole tree on every call. Use cache
74
+ instead The cache is invalidated on `post`, `update_one`, and when reassigning
75
+ `json_file`.
76
+
77
+ Tests:
78
+ - Rewrite `tests/test_offline.py` automatically with claude to adapt to knew format
79
+
80
+ # v1.2
81
+
82
+ Features:
83
+ - Support recursive pagination in `download_database` to bypass server-side query limits of 1000 items
84
+ - Add `cross_project_entity` parameter to `get` method to allow querying entities across projects
85
+ - Modernize project configuration by switching to `pyproject.toml`
86
+ - Improve token refresh and retry logic
87
+
88
+ Bugfixes:
89
+ - Fix `OfflineFlexilims` to correctly filter entities by project in `get` method and assign `project` field in `post` method
90
+
91
+ # v1.1
92
+
93
+ Minor:
94
+ - Add `limit` parameter to `get` method
95
+
96
+ # v1.0
97
+
98
+ Major:
99
+ - Add `cross_project_entity` (default to False) in get entry point. Required for requesting entity by name or id without specifying their type.
100
+
101
+ Minor:
102
+ - Remove case warning when uploading attributes
103
+
104
+ # v0.9
105
+
106
+ - Add an `offline` mode to emulate database access from a YAML file
107
+
108
+ # v0.8
109
+
110
+ Minor:
111
+ - Remove wrong warning when status code is 200
112
+
113
+ # v0.7
114
+
115
+ - Add a `safe_execute` method to `Flexilims.Session` to token refresh. This method
116
+ is used inside all other methods to ensure that the token is valid before
117
+ executing the request. If the token is invalid, the method will try to refresh
118
+ it and execute the request again. If the token cannot be refreshed, the method
119
+ will raise an error.
120
+
121
+ # v0.6
122
+ 2023-06-01
123
+
124
+ - Add `offline` module to download a JSON file version of the database
125
+ - Refactor functions useful in both online and offline mode into a `utils` module
126
+ - Create an `OffFlexilims` class to handle offline mode
127
+ - `Flexilims.Session` can be given a token at creation
128
+
129
+ # v0.5
130
+
131
+ - Add `delete` method to delete an entity
132
+ - Move password management to flexiznam as it is lab specific.
133
+
134
+ # v0.4
135
+
136
+ - Crash if uploading attribute with special characters in names and print warning when
137
+ uploading a non-lowercase attribute
138
+
139
+ # v0.3
140
+
141
+ - Add `get_project_info` to access new end-point giving project info.
142
+ - Crash if trying to upload an attribute name with special characters
143
+
144
+ ## Minor
145
+ - Raise error when setting `Flexilims.project_id` to something else than a 24
146
+ character hexadecimal string.
147
+ - Print a warning when setting an attribute name with non-lowercase characters
148
+
149
+ # v0.2
150
+
151
+ - Change how `null` values and empty structures are handled. See README.md
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Znamenskiy lab
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,10 @@
1
+ include LICENSE
2
+ include README.md
3
+ include CHANGELOG.md
4
+ include *.lock
5
+ exclude .pre-commit-config.yaml
6
+
7
+ recursive-exclude * __pycache__
8
+ recursive-exclude * *.py[co]
9
+ recursive-exclude docs *
10
+ recursive-exclude tests *