cmsdials 1.7.0__tar.gz → 1.7.2__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 (80) hide show
  1. cmsdials-1.7.2/.editorconfig +20 -0
  2. cmsdials-1.7.2/.gitignore +167 -0
  3. cmsdials-1.7.2/.gitlab-ci.yml +113 -0
  4. cmsdials-1.7.2/.mailmap +2 -0
  5. cmsdials-1.7.2/.pre-commit-config.yaml +25 -0
  6. cmsdials-1.7.2/.tool-versions +1 -0
  7. {cmsdials-1.7.0 → cmsdials-1.7.2}/PKG-INFO +44 -17
  8. {cmsdials-1.7.0 → cmsdials-1.7.2}/README.md +32 -0
  9. cmsdials-1.7.2/cmsdials/_version.py +21 -0
  10. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/auth/bearer.py +7 -5
  11. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/auth/client.py +3 -6
  12. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/oms_proxy/client.py +12 -7
  13. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/utils/api_client.py +1 -4
  14. cmsdials-1.7.2/cmsdials.egg-info/PKG-INFO +383 -0
  15. cmsdials-1.7.2/cmsdials.egg-info/SOURCES.txt +76 -0
  16. cmsdials-1.7.2/cmsdials.egg-info/dependency_links.txt +1 -0
  17. cmsdials-1.7.2/cmsdials.egg-info/requires.txt +9 -0
  18. cmsdials-1.7.2/cmsdials.egg-info/top_level.txt +1 -0
  19. cmsdials-1.7.2/pyproject.toml +55 -0
  20. cmsdials-1.7.2/ruff.toml +50 -0
  21. cmsdials-1.7.2/setup.cfg +4 -0
  22. cmsdials-1.7.2/tests/integration/__init__.py +0 -0
  23. cmsdials-1.7.2/tests/integration/test_auth_client.py +61 -0
  24. cmsdials-1.7.2/tests/integration/test_file_index_client.py +47 -0
  25. cmsdials-1.7.2/tests/integration/test_h1d_client.py +49 -0
  26. cmsdials-1.7.2/tests/integration/test_h2d_client.py +49 -0
  27. cmsdials-1.7.2/tests/integration/test_lumisection_client.py +49 -0
  28. cmsdials-1.7.2/tests/integration/test_mes_client.py +46 -0
  29. cmsdials-1.7.2/tests/integration/test_oms_proxy_client.py +37 -0
  30. cmsdials-1.7.2/tests/integration/test_resume.py +45 -0
  31. cmsdials-1.7.2/tests/integration/test_run_client.py +47 -0
  32. cmsdials-1.7.2/tests/integration/utils.py +15 -0
  33. cmsdials-1.7.2/tests/unit/__init__.py +0 -0
  34. cmsdials-1.7.2/tests/unit/test_base_api_client.py +20 -0
  35. cmsdials-1.7.2/tox.ini +9 -0
  36. cmsdials-1.7.0/cmsdials/_version.py +0 -1
  37. cmsdials-1.7.0/pyproject.toml +0 -149
  38. {cmsdials-1.7.0 → cmsdials-1.7.2}/LICENSE +0 -0
  39. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/__init__.py +0 -0
  40. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/auth/__init__.py +0 -0
  41. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/auth/_base.py +0 -0
  42. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/auth/exceptions.py +0 -0
  43. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/auth/models.py +0 -0
  44. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/auth/secret_key.py +0 -0
  45. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/__init__.py +0 -0
  46. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/dataset_index/__init__.py +0 -0
  47. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/dataset_index/client.py +0 -0
  48. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/dataset_index/models.py +0 -0
  49. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/file_index/__init__.py +0 -0
  50. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/file_index/client.py +0 -0
  51. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/file_index/models.py +0 -0
  52. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/h1d/__init__.py +0 -0
  53. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/h1d/client.py +0 -0
  54. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/h1d/models.py +0 -0
  55. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/h2d/__init__.py +0 -0
  56. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/h2d/client.py +0 -0
  57. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/h2d/models.py +0 -0
  58. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/lumisection/__init__.py +0 -0
  59. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/lumisection/client.py +0 -0
  60. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/lumisection/models.py +0 -0
  61. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/mes/__init__.py +0 -0
  62. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/mes/client.py +0 -0
  63. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/mes/models.py +0 -0
  64. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/ml_bad_lumisection/__init__.py +0 -0
  65. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/ml_bad_lumisection/client.py +0 -0
  66. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/ml_bad_lumisection/models.py +0 -0
  67. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/ml_models_index/__init__.py +0 -0
  68. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/ml_models_index/client.py +0 -0
  69. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/ml_models_index/models.py +0 -0
  70. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/oms_proxy/__init__.py +0 -0
  71. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/oms_proxy/models.py +0 -0
  72. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/run/__init__.py +0 -0
  73. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/run/client.py +0 -0
  74. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/clients/run/models.py +0 -0
  75. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/cmsdials.py +0 -0
  76. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/filters.py +0 -0
  77. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/utils/__init__.py +0 -0
  78. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/utils/_json.py +0 -0
  79. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/utils/base_model.py +0 -0
  80. {cmsdials-1.7.0 → cmsdials-1.7.2}/cmsdials/utils/logger.py +0 -0
@@ -0,0 +1,20 @@
1
+ # For VSCode install the extension: https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
2
+ # top-most EditorConfig file
3
+ root = true
4
+
5
+ [*]
6
+ indent_style = space
7
+ indent_size = 4
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+ end_of_line = lf
12
+
13
+ [*.md]
14
+ trim_trailing_whitespace = false
15
+
16
+ [Makefile]
17
+ indent_style = tab
18
+
19
+ [*.{yml,yaml,json}]
20
+ indent_size = 2
@@ -0,0 +1,167 @@
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
+ .cache-dev
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
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
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/#use-with-ide
111
+ .pdm.toml
112
+
113
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ #.idea/
162
+
163
+ # uv
164
+ uv.lock
165
+
166
+ # setuptools_scm
167
+ cmsdials/_version.py
@@ -0,0 +1,113 @@
1
+ stages:
2
+ - test
3
+ - build
4
+ - publish
5
+ - create_release
6
+
7
+ test_matrix:
8
+ stage: test
9
+ parallel:
10
+ matrix:
11
+ - PYTHON_VERSION: ["3.9", "3.10", "3.11", "3.12"]
12
+ image: registry.cern.ch/docker.io/library/python:$PYTHON_VERSION
13
+ before_script:
14
+ - python -m pip install --upgrade pip
15
+ - pip install uv
16
+ - uv sync --all-groups --extra pandas --extra tqdm
17
+ script:
18
+ - uv run pytest tests --cov=cmsdials --cov-report=xml --cov-report=term
19
+ coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
20
+ artifacts:
21
+ reports:
22
+ coverage_report:
23
+ coverage_format: cobertura
24
+ path: coverage.xml
25
+ variables:
26
+ SECRET_KEY: "$SECRET_KEY"
27
+
28
+ build:
29
+ stage: build
30
+ image: registry.cern.ch/docker.io/library/python:3.12
31
+ before_script:
32
+ - python -m pip install --upgrade pip
33
+ - pip install uv
34
+ - uv sync --all-groups --extra pandas --extra tqdm
35
+ script:
36
+ - rm -rf dist/
37
+ - uv build
38
+ artifacts:
39
+ paths:
40
+ - dist/
41
+ expire_in: 1 hour
42
+ needs:
43
+ - test_matrix
44
+
45
+ publish:
46
+ stage: publish
47
+ image: registry.cern.ch/docker.io/library/python:3.12
48
+ rules:
49
+ - if: '$CI_COMMIT_TAG'
50
+ when: always
51
+ - when: never
52
+ before_script:
53
+ - python -m pip install --upgrade pip
54
+ - pip install uv
55
+ script:
56
+ - uv publish # UV_PUBLISH_TOKEN has to be set in CI/CD variables
57
+ needs:
58
+ - build
59
+
60
+ create_release:
61
+ stage: create_release
62
+ image: registry.cern.ch/registry.gitlab.com/gitlab-org/cli:latest
63
+ rules:
64
+ - if: $CI_COMMIT_TAG
65
+ variables:
66
+ GITLAB_HOST: $CI_SERVER_FQDN
67
+ before_script:
68
+ - apk add jq --no-cache
69
+ script:
70
+ - |
71
+ set -x
72
+
73
+ # Fetch all tags
74
+ git fetch --tags
75
+
76
+ # Get the previous tag
77
+ PREV_TAG=$(git describe --tags --abbrev=0 ${CI_COMMIT_TAG}^)
78
+ echo "Generating release for ${CI_COMMIT_TAG} (MRs since ${PREV_TAG})"
79
+
80
+ # Setup auth
81
+ glab auth login --token "$GITLAB_TOKEN"
82
+
83
+ # Generate release notes
84
+ echo "### Changes since ${PREV_TAG}:" > release_notes.md
85
+ echo "" >> release_notes.md
86
+ echo "[${PREV_TAG}...${CI_COMMIT_TAG}]($CI_PROJECT_URL/-/compare/${PREV_TAG}...${CI_COMMIT_TAG})" >> release_notes.md
87
+ echo "" >> release_notes.md
88
+
89
+ # Get MR numbers between the two tags by parsing commit messages
90
+ MR_NUMBERS=$(git log $PREV_TAG..$CI_COMMIT_TAG --merges --pretty=format:"%b" | grep -oE '!([0-9]+)' | tr -d '!' | sort -u)
91
+
92
+ # Update release notes, fallback to commit list if merge request list is empty
93
+ # The default merge commit message has this at the end: See merge request gamoreir/test-release-ci!3
94
+ if [ -z "$MR_NUMBERS" ]; then
95
+ COMMIT_LIST=$(git log --pretty=format:"- #%h from %an <%ae>: %s" ${PREV_TAG}..${CI_COMMIT_TAG})
96
+ echo "${COMMIT_LIST}" >> release_notes.md
97
+ else
98
+ for mr in $MR_NUMBERS; do
99
+ echo "Fetching MR $mr metadata"
100
+ mr_metadata=$(glab mr view "$mr" -R "$CI_PROJECT_PATH" -F json)
101
+ mr_web_url=$(echo "$mr_metadata" | jq -r '.web_url')
102
+ title=$(echo "$mr_metadata" | jq -r '.title')
103
+ author_username=$(echo "$mr_metadata" | jq -r '.author.username')
104
+ author_username_web_url=$(echo "$mr_metadata" | jq -r '.author.web_url')
105
+ echo "- [!${mr}](${mr_web_url}) from [@${author_username}](${author_username_web_url}): ${title}" >> release_notes.md
106
+ done
107
+ fi
108
+
109
+ # Create the release
110
+ echo "Creating release for tag $CI_COMMIT_TAG"
111
+ glab release create "${CI_COMMIT_TAG}" -R "$CI_PROJECT_PATH" -F release_notes.md
112
+ needs:
113
+ - publish
@@ -0,0 +1,2 @@
1
+ Gabriel Moreira <gabriel.moreira@cern.ch> <gabrielmscampos@gmail.com>
2
+ Yueh-Shun Li <yueh-shun.li@cern.ch> <shamrocklee@posteo.net>
@@ -0,0 +1,25 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.5.0
4
+ hooks:
5
+ - id: check-added-large-files
6
+ args: ["--maxkb=500"]
7
+ exclude: >
8
+ (?x)^(
9
+ package-lock\.json
10
+ poetry\.lock
11
+ )$
12
+ - id: fix-byte-order-marker
13
+ - id: check-case-conflict
14
+ - id: check-merge-conflict
15
+ - id: check-symlinks
16
+ - id: debug-statements
17
+ - id: detect-private-key
18
+ - id: trailing-whitespace
19
+ - id: end-of-file-fixer
20
+ - repo: https://github.com/astral-sh/ruff-pre-commit
21
+ rev: v0.3.2
22
+ hooks:
23
+ - id: ruff
24
+ args: [--fix]
25
+ - id: ruff-format
@@ -0,0 +1 @@
1
+ python 3.12.9 3.11.10 3.10.13 3.9.19
@@ -1,29 +1,25 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: cmsdials
3
- Version: 1.7.0
3
+ Version: 1.7.2
4
4
  Summary: The Python api client interface to DIALS service
5
- Home-page: https://github.com/cms-DQM/dials-py
6
- Author: Gabriel Moreira
7
- Author-email: gabrielmscampos@gmail.com
8
- Requires-Python: >=3.9,<4.0
5
+ Author-email: Gabriel Moreira <gabriel.moreira@cern.ch>
6
+ Project-URL: Repository, https://gitlab.cern.ch/cms-dqmdc/libraries/dials-py
9
7
  Classifier: Development Status :: 5 - Production/Stable
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Programming Language :: Python
12
- Classifier: Programming Language :: Python :: 3
13
8
  Classifier: Programming Language :: Python :: 3.9
14
9
  Classifier: Programming Language :: Python :: 3.10
15
10
  Classifier: Programming Language :: Python :: 3.11
16
11
  Classifier: Programming Language :: Python :: 3.12
17
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: requests<3.0.0,>=2.31.0
16
+ Requires-Dist: urllib3<2.0.0,>=1.26.16
17
+ Requires-Dist: pydantic<3.0.0,>=2.8.2
18
18
  Provides-Extra: pandas
19
+ Requires-Dist: pandas>=1.5.3; extra == "pandas"
19
20
  Provides-Extra: tqdm
20
- Requires-Dist: pandas (>=1.5.3) ; extra == "pandas"
21
- Requires-Dist: pydantic (>=2.8.2,<3.0.0)
22
- Requires-Dist: requests (>=2.31.0,<3.0.0)
23
- Requires-Dist: tqdm (>=4.66.1) ; extra == "tqdm"
24
- Requires-Dist: urllib3 (>=1.26.16,<2.0.0)
25
- Project-URL: Repository, https://github.com/cms-DQM/dials-py
26
- Description-Content-Type: text/markdown
21
+ Requires-Dist: tqdm>=4.66.1; extra == "tqdm"
22
+ Dynamic: license-file
27
23
 
28
24
  ![Build Status](https://gitlab.cern.ch/cms-dqmdc/libraries/dials-py/badges/dev/pipeline.svg)
29
25
  ![Coverage](https://gitlab.cern.ch/cms-dqmdc/libraries/dials-py/badges/dev/coverage.svg)
@@ -354,3 +350,34 @@ asdf set python 3.12.9 3.11.10 3.10.13 3.9.19
354
350
 
355
351
  This will use `3.12.9` by default (if you just run `python`), but it will also put `python3.11`, `python3.10` and `python3.9` symlinks in your path so you can run those too (which is exactly what tox is looking for).
356
352
 
353
+ ## Releasing the package on PyPI
354
+
355
+ ### Build
356
+
357
+ You can use poetry to build the package using:
358
+
359
+ ```bash
360
+ poetry build
361
+ ```
362
+
363
+ The build system requires `poetry-dynamic-versioning` plugin installed to update the package version during build time. To install this plugin simply:
364
+
365
+ ```
366
+ poetry self add "poetry-dynamic-versioning[plugin]"
367
+ ```
368
+
369
+ The build system will automatically update the package version based on the git tag of the current commit.
370
+
371
+ ### Publish
372
+
373
+ To publish the package will need maintainer rights to the `cmsdials` page in PyPI and configure your poetry installation to publish with a PyPI api token. Provided you have already generate a PyPI api token in your account you can configure your poetry installation using:
374
+
375
+ ```
376
+ poetry config pypi-token.pypi <your-api-token>
377
+ ```
378
+
379
+ Then, to build and publish in one go you can do:
380
+
381
+ ```bash
382
+ poetry publish --build
383
+ ```
@@ -326,3 +326,35 @@ asdf set python 3.12.9 3.11.10 3.10.13 3.9.19
326
326
  ```
327
327
 
328
328
  This will use `3.12.9` by default (if you just run `python`), but it will also put `python3.11`, `python3.10` and `python3.9` symlinks in your path so you can run those too (which is exactly what tox is looking for).
329
+
330
+ ## Releasing the package on PyPI
331
+
332
+ ### Build
333
+
334
+ You can use poetry to build the package using:
335
+
336
+ ```bash
337
+ poetry build
338
+ ```
339
+
340
+ The build system requires `poetry-dynamic-versioning` plugin installed to update the package version during build time. To install this plugin simply:
341
+
342
+ ```
343
+ poetry self add "poetry-dynamic-versioning[plugin]"
344
+ ```
345
+
346
+ The build system will automatically update the package version based on the git tag of the current commit.
347
+
348
+ ### Publish
349
+
350
+ To publish the package will need maintainer rights to the `cmsdials` page in PyPI and configure your poetry installation to publish with a PyPI api token. Provided you have already generate a PyPI api token in your account you can configure your poetry installation using:
351
+
352
+ ```
353
+ poetry config pypi-token.pypi <your-api-token>
354
+ ```
355
+
356
+ Then, to build and publish in one go you can do:
357
+
358
+ ```bash
359
+ poetry publish --build
360
+ ```
@@ -0,0 +1,21 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
6
+ TYPE_CHECKING = False
7
+ if TYPE_CHECKING:
8
+ from typing import Tuple
9
+ from typing import Union
10
+
11
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
12
+ else:
13
+ VERSION_TUPLE = object
14
+
15
+ version: str
16
+ __version__: str
17
+ __version_tuple__: VERSION_TUPLE
18
+ version_tuple: VERSION_TUPLE
19
+
20
+ __version__ = version = '1.7.2'
21
+ __version_tuple__ = version_tuple = (1, 7, 2)
@@ -31,7 +31,7 @@ class Credentials(BaseCredentials):
31
31
  refresh_expires_in: int,
32
32
  refresh_token: str,
33
33
  token_type: str,
34
- cache_dir: str = DEFAULT_CACHE_DIR,
34
+ cache_dir: Optional[str] = None,
35
35
  client: Optional[AuthClient] = None,
36
36
  ):
37
37
  # Load parent class and overwrite token attributes
@@ -45,7 +45,7 @@ class Credentials(BaseCredentials):
45
45
  self.token_type = token_type
46
46
 
47
47
  # Setup dir for caching credentials and authentication client
48
- self.cache_dir = cache_dir
48
+ self.cache_dir = cache_dir or DEFAULT_CACHE_DIR
49
49
  self.client = client or AuthClient()
50
50
 
51
51
  # If loaded token is expired, immediately refresh
@@ -75,7 +75,7 @@ class Credentials(BaseCredentials):
75
75
  )
76
76
 
77
77
  @staticmethod
78
- def _handle_creds_filepath(cache_dir: str = DEFAULT_CACHE_DIR):
78
+ def _handle_creds_filepath(cache_dir: Optional[str] = None):
79
79
  cache_dir = cache_dir or DEFAULT_CACHE_DIR
80
80
  if os.path.isabs(cache_dir) is False:
81
81
  cache_dir = os.path.join(os.getcwd(), cache_dir)
@@ -85,9 +85,10 @@ class Credentials(BaseCredentials):
85
85
 
86
86
  @staticmethod
87
87
  def from_authclient_token(
88
- token: Token, cache_dir: str = DEFAULT_CACHE_DIR, client: Optional[AuthClient] = None
88
+ token: Token, cache_dir: Optional[str] = None, client: Optional[AuthClient] = None
89
89
  ) -> "Credentials":
90
90
  client = client or AuthClient()
91
+ cache_dir = cache_dir or DEFAULT_CACHE_DIR
91
92
  return Credentials(
92
93
  token=token.access_token,
93
94
  expires_in=token.expires_in,
@@ -101,8 +102,9 @@ class Credentials(BaseCredentials):
101
102
  )
102
103
 
103
104
  @staticmethod
104
- def from_creds_file(cache_dir: str = DEFAULT_CACHE_DIR, client: Optional[AuthClient] = None) -> "Credentials":
105
+ def from_creds_file(cache_dir: Optional[str] = None, client: Optional[AuthClient] = None) -> "Credentials":
105
106
  client = client or AuthClient()
107
+ cache_dir = cache_dir or DEFAULT_CACHE_DIR
106
108
  fpath = Credentials._handle_creds_filepath(cache_dir)
107
109
  try:
108
110
  with open(fpath) as filebuffer:
@@ -23,10 +23,7 @@ class AuthClient(BaseAPIClient):
23
23
  endpoint_url = self.api_url + "auth/new-device/"
24
24
  response = requests.get(
25
25
  url=endpoint_url,
26
- headers={
27
- "accept": "application/json",
28
- "User-Agent": self._build_user_agent()
29
- },
26
+ headers={"accept": "application/json", "User-Agent": self._build_user_agent()},
30
27
  timeout=self.default_timeout,
31
28
  )
32
29
  response.raise_for_status()
@@ -40,7 +37,7 @@ class AuthClient(BaseAPIClient):
40
37
  headers={
41
38
  "accept": "application/json",
42
39
  "Content-Type": "application/json",
43
- "User-Agent": self._build_user_agent()
40
+ "User-Agent": self._build_user_agent(),
44
41
  },
45
42
  json={"device_code": device_code},
46
43
  timeout=self.default_timeout,
@@ -67,7 +64,7 @@ class AuthClient(BaseAPIClient):
67
64
  "accept": "application/json",
68
65
  "Content-Type": "application/json",
69
66
  "Authorization": f"{token_type} {access_token}",
70
- "User-Agent": self._build_user_agent()
67
+ "User-Agent": self._build_user_agent(),
71
68
  },
72
69
  json={"refresh_token": refresh_token},
73
70
  timeout=self.default_timeout,
@@ -1,7 +1,7 @@
1
1
  from typing import Optional
2
2
 
3
- import requests
4
3
  from requests.exceptions import HTTPError
4
+ from requests.adapters import DEFAULT_RETRIES
5
5
 
6
6
  from ...auth._base import BaseCredentials
7
7
  from ...utils.api_client import BaseAPIClient
@@ -23,14 +23,13 @@ class OMSProxyClient(BaseAPIClient):
23
23
  self.creds = creds
24
24
 
25
25
  def _build_headers(self) -> dict:
26
- base = {
27
- "accept": "application/json",
28
- "User-Agent": self._build_user_agent()
29
- }
26
+ base = {"Accept": "application/json", "User-Agent": self._build_user_agent()}
30
27
  self.creds.before_request(base)
31
28
  return base
32
29
 
33
- def query(self, endpoint: str, filters: list[OMSFilter], pages: Optional[list[OMSPage]] = None):
30
+ def query(
31
+ self, endpoint: str, filters: list[OMSFilter], pages: Optional[list[OMSPage]] = None, retries=DEFAULT_RETRIES
32
+ ):
34
33
  headers = self._build_headers()
35
34
  endpoint_url = self.api_url + self.lookup_url
36
35
 
@@ -39,7 +38,13 @@ class OMSProxyClient(BaseAPIClient):
39
38
  pages = {f"page[{page.attribute_name}]": page.value for page in pages} if pages and len(pages) > 0 else {}
40
39
  params = {"endpoint": endpoint, **filters, **pages}
41
40
 
42
- response = requests.get(endpoint_url, headers=headers, params=params, timeout=self.default_timeout)
41
+ response = self._requests_get_retriable(
42
+ endpoint_url,
43
+ headers=headers,
44
+ params=params,
45
+ timeout=self.default_timeout,
46
+ retries=retries,
47
+ )
43
48
  try:
44
49
  response.raise_for_status()
45
50
  except HTTPError as err:
@@ -84,10 +84,7 @@ class BaseAuthorizedAPIClient(BaseAPIClient):
84
84
  self.workspace = workspace
85
85
 
86
86
  def _build_headers(self) -> dict:
87
- base = {
88
- "accept": "application/json",
89
- "User-Agent": self._build_user_agent()
90
- }
87
+ base = {"Accept": "application/json", "User-Agent": self._build_user_agent()}
91
88
  if self.workspace is not None:
92
89
  base["Workspace"] = self.workspace
93
90
  self.creds.before_request(base)