orient_express 2.4.2__tar.gz → 3.0.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.
Files changed (66) hide show
  1. orient_express-3.0.0/.dockerignore +10 -0
  2. orient_express-3.0.0/.github/workflows/workflow.yaml +66 -0
  3. orient_express-3.0.0/.gitignore +177 -0
  4. orient_express-3.0.0/.python-version +1 -0
  5. orient_express-3.0.0/Makefile +134 -0
  6. orient_express-2.4.2/README.md → orient_express-3.0.0/PKG-INFO +52 -242
  7. orient_express-2.4.2/PKG-INFO → orient_express-3.0.0/README.md +28 -270
  8. orient_express-3.0.0/docker-image-onnx/Dockerfile +19 -0
  9. orient_express-3.0.0/docker-image-onnx/logging.conf +29 -0
  10. orient_express-3.0.0/docker-image-onnx/run_inference_server.py +120 -0
  11. orient_express-3.0.0/docker-xgboost-scikit-learn/Dockerfile +19 -0
  12. orient_express-3.0.0/docker-xgboost-scikit-learn/logging.conf +31 -0
  13. orient_express-3.0.0/docker-xgboost-scikit-learn/run_inference_server.py +54 -0
  14. orient_express-3.0.0/orient_express/__init__.py +40 -0
  15. orient_express-3.0.0/orient_express/predictors/__init__.py +90 -0
  16. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/predictors/classification.py +6 -1
  17. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/predictors/feature_extraction.py +9 -2
  18. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/predictors/instance_segmentation.py +77 -37
  19. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/predictors/multi_label_classification.py +1 -1
  20. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/predictors/object_detection.py +20 -9
  21. orient_express-3.0.0/orient_express/predictors/predictor.py +199 -0
  22. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/predictors/semantic_segmentation.py +11 -13
  23. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/predictors/vector_index.py +55 -43
  24. orient_express-3.0.0/orient_express/serving.py +103 -0
  25. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/utils/colors.py +2 -4
  26. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/utils/gs.py +8 -16
  27. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/utils/image_processor.py +70 -4
  28. orient_express-3.0.0/orient_express/utils/paths.py +23 -0
  29. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/utils/retry.py +2 -2
  30. {orient_express-2.4.2 → orient_express-3.0.0}/orient_express/vertex.py +146 -36
  31. orient_express-3.0.0/pyproject.toml +74 -0
  32. orient_express-3.0.0/test_docker_image.ipynb +337 -0
  33. orient_express-3.0.0/tests/conftest.py +6 -0
  34. orient_express-3.0.0/tests/equivalence/README.md +127 -0
  35. orient_express-3.0.0/tests/equivalence/__init__.py +0 -0
  36. orient_express-3.0.0/tests/equivalence/conftest.py +75 -0
  37. orient_express-3.0.0/tests/equivalence/generate_goldens.py +151 -0
  38. orient_express-3.0.0/tests/equivalence/harness.py +605 -0
  39. orient_express-3.0.0/tests/equivalence/htmlreport.py +111 -0
  40. orient_express-3.0.0/tests/equivalence/manifest.example.yaml +38 -0
  41. orient_express-3.0.0/tests/equivalence/test_docker_equivalence.py +267 -0
  42. orient_express-3.0.0/tests/equivalence/test_equivalence.py +108 -0
  43. orient_express-3.0.0/tests/predictors/__init__.py +0 -0
  44. orient_express-3.0.0/tests/predictors/conftest.py +94 -0
  45. orient_express-3.0.0/tests/predictors/test_classification.py +156 -0
  46. orient_express-3.0.0/tests/predictors/test_collate.py +66 -0
  47. orient_express-3.0.0/tests/predictors/test_instance_segmentation.py +244 -0
  48. orient_express-3.0.0/tests/predictors/test_multi_label_classification.py +236 -0
  49. orient_express-3.0.0/tests/predictors/test_object_detection.py +322 -0
  50. orient_express-3.0.0/tests/predictors/test_semantic_segmentation.py +191 -0
  51. orient_express-3.0.0/tests/predictors/test_vector_index.py +454 -0
  52. orient_express-3.0.0/tests/test_image_processor.py +54 -0
  53. orient_express-3.0.0/tests/test_paths.py +15 -0
  54. orient_express-3.0.0/tests/test_registry.py +76 -0
  55. orient_express-3.0.0/tests/test_resize_masks.py +69 -0
  56. orient_express-3.0.0/tests/test_serving.py +152 -0
  57. orient_express-3.0.0/tests/test_vertex.py +1345 -0
  58. orient_express-3.0.0/uv.lock +2936 -0
  59. orient_express-2.4.2/orient_express/__init__.py +0 -1
  60. orient_express-2.4.2/orient_express/deployment.py +0 -97
  61. orient_express-2.4.2/orient_express/model_wrapper.py +0 -255
  62. orient_express-2.4.2/orient_express/predictors/__init__.py +0 -105
  63. orient_express-2.4.2/orient_express/predictors/predictor.py +0 -107
  64. orient_express-2.4.2/orient_express/sklearn_pipeline.py +0 -81
  65. orient_express-2.4.2/orient_express/utils/paths.py +0 -6
  66. orient_express-2.4.2/pyproject.toml +0 -36
@@ -0,0 +1,10 @@
1
+ orient_express/artifacts
2
+ **/*.onnx
3
+ **/*.pth
4
+ **/*.pt
5
+ **/*.joblib
6
+ **/*.ipynb
7
+ **/__pycache__
8
+ test-output
9
+ .git
10
+ .venv
@@ -0,0 +1,66 @@
1
+ name: Test and publish
2
+
3
+ on:
4
+ push:
5
+ branches: ["**"]
6
+ tags: ["v*"]
7
+
8
+ jobs:
9
+ build-and-test:
10
+ name: Build and test
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v7
16
+ with:
17
+ enable-cache: true
18
+ - name: Install dependencies
19
+ # onnxruntime-gpu (selected by platform marker on linux-x86_64) needs
20
+ # CUDA libs at import since 1.27; runners have none, so install the
21
+ # CPU wheel instead — same swap the serving Dockerfiles do.
22
+ run: |
23
+ uv sync --frozen --no-install-package onnxruntime-gpu
24
+ uv pip install "onnxruntime>=1.20,<2"
25
+ - name: Lint with ruff
26
+ run: uv run --no-sync ruff check .
27
+ - name: Check formatting with ruff
28
+ run: uv run --no-sync ruff format --check .
29
+ - name: Run tests with pytest
30
+ run: uv run --no-sync pytest
31
+ - name: Build a binary wheel and a source tarball
32
+ run: uv build
33
+ - name: Store the distribution packages
34
+ uses: actions/upload-artifact@v4
35
+ with:
36
+ name: python-package-distributions
37
+ path: dist/
38
+
39
+ publish-to-pypi:
40
+ name: Publish to PyPI
41
+ runs-on: ubuntu-latest
42
+ if: startsWith(github.ref, 'refs/tags/v')
43
+ needs: build-and-test
44
+ environment: release
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+
48
+ - name: Install uv
49
+ uses: astral-sh/setup-uv@v7
50
+
51
+ - name: Check tag matches project version
52
+ run: |
53
+ TAG_VERSION="${GITHUB_REF_NAME#v}"
54
+ PROJECT_VERSION="$(uv version --short)"
55
+ if [ "$TAG_VERSION" != "$PROJECT_VERSION" ]; then
56
+ echo "Tag $GITHUB_REF_NAME does not match pyproject version $PROJECT_VERSION" >&2
57
+ exit 1
58
+ fi
59
+
60
+ - name: Build the package
61
+ run: uv build
62
+
63
+ - name: Upload package to PyPI
64
+ run: uv publish --token "$UV_PUBLISH_TOKEN"
65
+ env:
66
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,177 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *~
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
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/latest/usage/project/#working-with-version-control
111
+ .pdm.toml
112
+ .pdm-python
113
+ .pdm-build/
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ .idea/
164
+ .envrc
165
+ .venv
166
+
167
+ # Ignore artifacts:
168
+ orient_express/artifacts/
169
+ *.onnx
170
+ *.pt
171
+ *.pth
172
+
173
+ # Local docker test outputs
174
+ test-output/
175
+ *.joblib
176
+ /test.ipynb
177
+ *.local.ipynb
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,134 @@
1
+ # --- Development ---
2
+
3
+ install:
4
+ uv sync
5
+
6
+ fmt:
7
+ uv run ruff format .
8
+ uv run ruff check --fix .
9
+
10
+ lint:
11
+ uv run ruff check .
12
+ uv run ruff format --check .
13
+
14
+ test:
15
+ uv run pytest
16
+
17
+ # Golden equivalence suite (internal — see tests/equivalence/README.md).
18
+ # Requires ORIENT_EXPRESS_TEST_MANIFEST and GCP application-default creds;
19
+ # equivalence-docker additionally needs GOOGLE_CLOUD_PROJECT.
20
+ equivalence:
21
+ uv run pytest tests/equivalence -v
22
+
23
+ equivalence-docker: build_local_image_onnx
24
+ GOOGLE_CLOUD_PROJECT=$(GOOGLE_CLOUD_PROJECT) \
25
+ ORIENT_EXPRESS_TEST_DOCKER_IMAGE=$(IMAGE_ONNX):$(IMAGE_ONNX_TAG)_local \
26
+ uv run pytest tests/equivalence -v
27
+
28
+ # Work on a gitignored copy of the committed test notebook so ad-hoc cell
29
+ # edits and outputs never end up in a commit. To update the committed
30
+ # template, deliberately edit test_docker_image.ipynb itself.
31
+ scratch-notebook:
32
+ cp -n test_docker_image.ipynb test_docker_image.local.ipynb
33
+ @echo "Opened copy: test_docker_image.local.ipynb (gitignored)"
34
+
35
+ .PHONY: install fmt lint test equivalence equivalence-docker scratch-notebook
36
+
37
+ # --- Docker images ---
38
+ # Image tags track the library version in pyproject.toml (see
39
+ # get_image_onnx_container_uri in orient_express/predictors/predictor.py).
40
+
41
+ VERSION := $(shell uv version --short)
42
+
43
+ XGBOOST_SCIKIT_LEARN := us-west1-docker.pkg.dev/shiftsmart-api/orient-express/xgboost-scikit-learn
44
+ XGBOOST_TAG := v$(VERSION)
45
+
46
+ IMAGE_ONNX := us-west1-docker.pkg.dev/shiftsmart-api/orient-express/image-onnx
47
+ IMAGE_ONNX_TAG := v$(VERSION)
48
+
49
+ GOOGLE_CLOUD_PROJECT ?=
50
+ REGION ?= us-west1
51
+ MODEL_NAME ?=
52
+ IMAGE_URL ?=
53
+ CONFIDENCE ?= 0.5
54
+
55
+ # Looked up from Vertex AI Model Registry by MODEL_NAME if not provided.
56
+ AIP_STORAGE_URI ?= $(shell gcloud ai models list \
57
+ --region=$(REGION) --project=$(GOOGLE_CLOUD_PROJECT) \
58
+ --filter='displayName=$(MODEL_NAME)' \
59
+ --sort-by='~createTime' --limit=1 \
60
+ --format='value(name)' | \
61
+ xargs -I {} gcloud ai models describe {} \
62
+ --region=$(REGION) --project=$(GOOGLE_CLOUD_PROJECT) \
63
+ --format='value(artifactUri)')
64
+
65
+ print_aip_storage_uri:
66
+ @echo "REGION=$(REGION)"
67
+ @echo "GOOGLE_CLOUD_PROJECT=$(GOOGLE_CLOUD_PROJECT)"
68
+ @echo "MODEL_NAME=$(MODEL_NAME)"
69
+ @echo "--- step 1: model resource name ---"
70
+ @gcloud ai models list \
71
+ --region=$(REGION) --project=$(GOOGLE_CLOUD_PROJECT) \
72
+ --filter='displayName=$(MODEL_NAME)' \
73
+ --sort-by='~createTime' --limit=1 \
74
+ --format='value(name)'
75
+ @echo "--- step 2: artifact URI ---"
76
+ @gcloud ai models list \
77
+ --region=$(REGION) --project=$(GOOGLE_CLOUD_PROJECT) \
78
+ --filter='displayName=$(MODEL_NAME)' \
79
+ --sort-by='~createTime' --limit=1 \
80
+ --format='value(name)' | \
81
+ xargs -I {} gcloud ai models describe {} \
82
+ --region=$(REGION) --project=$(GOOGLE_CLOUD_PROJECT) \
83
+ --format='value(artifactUri)'
84
+ @echo "--- resolved AIP_STORAGE_URI ---"
85
+ @echo $(AIP_STORAGE_URI)
86
+
87
+ build_local_xgboost_scikit_learn:
88
+ docker buildx build --tag $(XGBOOST_SCIKIT_LEARN):$(XGBOOST_TAG)_local -f docker-xgboost-scikit-learn/Dockerfile .
89
+
90
+ build_xgboost_scikit_learn:
91
+ docker buildx build --platform linux/amd64 --tag $(XGBOOST_SCIKIT_LEARN):$(XGBOOST_TAG) -f docker-xgboost-scikit-learn/Dockerfile .
92
+
93
+ push_xgboost_scikit_learn: build_xgboost_scikit_learn
94
+ docker push $(XGBOOST_SCIKIT_LEARN):$(XGBOOST_TAG)
95
+
96
+ run_local_xgboost_scikit_learn:
97
+ docker run --rm \
98
+ -v ~/.config/gcloud/application_default_credentials.json:/root/.config/gcloud/application_default_credentials.json:ro \
99
+ -e GOOGLE_APPLICATION_CREDENTIALS=/root/.config/gcloud/application_default_credentials.json \
100
+ -e GOOGLE_CLOUD_PROJECT=$(GOOGLE_CLOUD_PROJECT) \
101
+ -e AIP_STORAGE_URI=$(AIP_STORAGE_URI) \
102
+ -e MODEL_NAME=$(MODEL_NAME) \
103
+ -p 8080:8080 $(XGBOOST_SCIKIT_LEARN):$(XGBOOST_TAG)_local
104
+
105
+ build_local_image_onnx:
106
+ docker buildx build --tag $(IMAGE_ONNX):$(IMAGE_ONNX_TAG)_local -f docker-image-onnx/Dockerfile .
107
+
108
+ build_image_onnx:
109
+ docker buildx build --platform linux/amd64 --tag $(IMAGE_ONNX):$(IMAGE_ONNX_TAG) -f docker-image-onnx/Dockerfile .
110
+
111
+ push_image_onnx: build_image_onnx
112
+ docker push $(IMAGE_ONNX):$(IMAGE_ONNX_TAG)
113
+
114
+ run_local_image_onnx:
115
+ docker run --rm \
116
+ -v ~/.config/gcloud/application_default_credentials.json:/root/.config/gcloud/application_default_credentials.json:ro \
117
+ -e GOOGLE_APPLICATION_CREDENTIALS=/root/.config/gcloud/application_default_credentials.json \
118
+ -e GOOGLE_CLOUD_PROJECT=$(GOOGLE_CLOUD_PROJECT) \
119
+ -e AIP_STORAGE_URI=$(AIP_STORAGE_URI) \
120
+ -e MODEL_NAME=$(MODEL_NAME) \
121
+ -p 8080:8080 $(IMAGE_ONNX):$(IMAGE_ONNX_TAG)_local
122
+
123
+ test_image_onnx:
124
+ mkdir -p test-output
125
+ @RESP=$$(mktemp); \
126
+ trap "rm -f $$RESP" EXIT; \
127
+ curl -s -X POST http://localhost:8080/v1/models/$(MODEL_NAME):predict \
128
+ -H "Content-Type: application/json" \
129
+ -d '{"instances": [{"image": "$(IMAGE_URL)"}], "parameters": {"confidence": $(CONFIDENCE)}}' \
130
+ -o $$RESP && \
131
+ jq -r '.predictions[0].debug_image // empty' $$RESP | base64 -d > test-output/debug_image.jpg && \
132
+ jq -r '.predictions[0].predictions.class_mask // empty' $$RESP | base64 -d > test-output/class_mask.png && \
133
+ jq -r '.predictions[0].predictions.valid_mask // empty' $$RESP | base64 -d > test-output/valid_mask.png && \
134
+ jq 'del(.predictions[].debug_image?, .predictions[].predictions.class_mask?, .predictions[].predictions.valid_mask?)' $$RESP > test-output/response.json