latticeflow-core 3.8.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 (25) hide show
  1. latticeflow_core-3.8.0/.gitignore +290 -0
  2. latticeflow_core-3.8.0/PKG-INFO +7 -0
  3. latticeflow_core-3.8.0/hatch_build.py +203 -0
  4. latticeflow_core-3.8.0/latticeflow/core/__init__.py +0 -0
  5. latticeflow_core-3.8.0/latticeflow/core/dtypes/__init__.py +241 -0
  6. latticeflow_core-3.8.0/latticeflow/core/dtypes/_assessment/__init__.py +0 -0
  7. latticeflow_core-3.8.0/latticeflow/core/dtypes/_assessment/base_model.py +250 -0
  8. latticeflow_core-3.8.0/latticeflow/core/dtypes/_assessment/models.py +4806 -0
  9. latticeflow_core-3.8.0/latticeflow/core/dtypes/_base_model.py +250 -0
  10. latticeflow_core-3.8.0/latticeflow/core/dtypes/_compat.py +25 -0
  11. latticeflow_core-3.8.0/latticeflow/core/dtypes/_evidence.py +142 -0
  12. latticeflow_core-3.8.0/latticeflow/core/dtypes/_judge.py +45 -0
  13. latticeflow_core-3.8.0/latticeflow/core/dtypes/_messages.py +159 -0
  14. latticeflow_core-3.8.0/latticeflow/core/dtypes/_model_io.py +262 -0
  15. latticeflow_core-3.8.0/latticeflow/core/dtypes/_open_responses/__init__.py +0 -0
  16. latticeflow_core-3.8.0/latticeflow/core/dtypes/_open_responses/base_model.py +251 -0
  17. latticeflow_core-3.8.0/latticeflow/core/dtypes/_open_responses/models.py +3063 -0
  18. latticeflow_core-3.8.0/latticeflow/core/dtypes/_progress.py +48 -0
  19. latticeflow_core-3.8.0/latticeflow/core/dtypes/_protocols.py +31 -0
  20. latticeflow_core-3.8.0/latticeflow/core/dtypes/_scoring.py +89 -0
  21. latticeflow_core-3.8.0/latticeflow/core/dtypes/_solver_output.py +213 -0
  22. latticeflow_core-3.8.0/latticeflow/core/dtypes/_trace.py +511 -0
  23. latticeflow_core-3.8.0/latticeflow/core/dtypes/_trace_converters.py +410 -0
  24. latticeflow_core-3.8.0/latticeflow/core/py.typed +0 -0
  25. latticeflow_core-3.8.0/pyproject.toml +57 -0
@@ -0,0 +1,290 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # OSX
10
+ .DS_Store
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ pip-wheel-metadata/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
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
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
102
+ __pypackages__/
103
+
104
+ # Celery stuff
105
+ celerybeat-schedule
106
+ celerybeat.pid
107
+
108
+ # SageMath parsed files
109
+ *.sage.py
110
+
111
+ # Environments
112
+ .env
113
+ .env.*
114
+ !.env.example
115
+ .venv
116
+ env/
117
+ venv/
118
+ venv3.6/
119
+ ENV/
120
+ env.bak/
121
+ venv.bak/
122
+
123
+ # Spyder project settings
124
+ .spyderproject
125
+ .spyproject
126
+
127
+ # Rope project settings
128
+ .ropeproject
129
+
130
+ # mkdocs documentation
131
+ /site
132
+
133
+ # mypy
134
+ .mypy_cache/
135
+ .dmypy.json
136
+ dmypy.json
137
+
138
+ # Pyre type checker
139
+ .pyre/
140
+
141
+ # pytype static type analyzer
142
+ .pytype/
143
+
144
+ # Cython debug symbols
145
+ cython_debug/
146
+
147
+ # JetBrains
148
+ .idea
149
+ .uuid
150
+
151
+ # VS Code
152
+ .vscode
153
+
154
+ # Pyright config (local only)
155
+ pyrightconfig.json
156
+
157
+ # SQLite
158
+ *.db
159
+ *.db3
160
+ *.sqlite
161
+ *.sqlite3
162
+
163
+ # Ignore temp and swap files
164
+ *~
165
+
166
+ # Temporary files
167
+ temp_link
168
+
169
+ # Packaged sources
170
+ dist_py_*
171
+
172
+ # License data.
173
+ .latticeflow/*
174
+
175
+ # Files created during testing
176
+ example_config_resaved*.json
177
+
178
+ # Ignore Numpy datafiles
179
+ *.npy
180
+
181
+ # Version files
182
+ **/latticeflow/*/version.py
183
+ **/latticeflow/**/version.py
184
+
185
+ # Benchmark files
186
+ benchmark/*/models/
187
+
188
+ # Cache
189
+ **lf_cache/
190
+ **latticeflow.db
191
+ **latticeflow.db-journal
192
+
193
+ # All migrations/ folders, except their implementation
194
+ migrations/
195
+ examples/**/migrations/
196
+ *latticeflow/**/migrations/
197
+ !ais/cloud/latticeflow/cloud/persistence/migrations/
198
+ !slicing/latticeflow/core/persistence/migrations/
199
+ !assessment/latticeflow/assessment/persistence/migrations/
200
+ !assessment/tests/test_integration/migrations/
201
+
202
+ # Torch models
203
+ **.pt
204
+ **.pth
205
+
206
+ # ONNX models
207
+ **.onnx
208
+
209
+ # Docker compose files
210
+ examples/docker-compose.blue.yml
211
+ examples/docker-compose.yuhuang.yml
212
+ examples/compcars/tf_model
213
+ examples/compcars/tf_model_classification
214
+ examples/web/tf_model_classification
215
+
216
+ # LatticeFlow cloud data
217
+ **lf_data/
218
+ **lf_data_dumps/
219
+
220
+ # Documentation
221
+ readme/out
222
+
223
+ # Automatically generated file
224
+ ais/tools/dev_docker/docker-compose.dev-full.yml
225
+ assessment/tools/dev_docker/docker-compose.dev-full.yml
226
+ assessment/tools/dev_docker/docker-compose.dev-setup-full.yml
227
+ assessment/tools/dev_docker/docker-compose.private-additions.yml
228
+
229
+ # User modified config
230
+ ais/tools/dev_docker/config.yaml
231
+ assessment/tools/dev_docker/config.yaml
232
+
233
+ # Temporary dev-docker volume mount
234
+ assessment/tools/dev_docker/conf.properties.tmp
235
+
236
+ # AIA data
237
+ assessment/data/aia-data
238
+
239
+ # AI Atlas zipped evals and manifest.json
240
+ assessment/tools/dev_docker/atlas
241
+
242
+ # Upload scripts generated by `lf_add_dataset`.
243
+ **/upload.py
244
+
245
+ # Prepare cache scripts generated by `lf_prepare_cache`.
246
+ **/prepare_cache.py
247
+
248
+ # Ignore lfrc file if it exists
249
+ .lfrc
250
+ .lfrc_tests
251
+
252
+ # Personal files not to be shared
253
+ personal/
254
+
255
+ # e2e test generated files
256
+ report.html
257
+ hoverfly_simulations/
258
+
259
+ # Celery related when it's running locally
260
+ celerybeat-schedule.*
261
+
262
+ # ignore lf readme docs
263
+ lf-readme-docs
264
+ docs/offline/html
265
+ # Generated types
266
+ front-end/**/generated/*.d.ts
267
+
268
+ # Ignore generated static folder in cloud
269
+ ais/cloud/latticeflow/cloud/static/
270
+
271
+ # LatticeFlow AI OpenAPI Bindings
272
+ openapi/assessment/latticeflow/
273
+ openapi/assessment/openapi-merged.yaml
274
+ openapi/open_responses/latticeflow/
275
+ openapi/open_responses/openapi-merged.json
276
+
277
+ # Background test container env file
278
+ assessment/tests/test_integration/test.env
279
+
280
+ !ais/cloud/latticeflow/cloud/utils/upload.py
281
+ !ais/cloud/docker_compose_templates/.env.oauth.example
282
+ !ais/sdk/latticeflow/sdk/scripts/prepare_cache.py
283
+ !ais/sdk/latticeflow/sdk/utils/upload.py
284
+
285
+ # LF CLI/SDK config files
286
+ .latticeflow.yaml
287
+
288
+ # LF Core build files
289
+ core/latticeflow/core/dtypes/_assessment/
290
+ core/latticeflow/core/dtypes/_open_responses/
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: latticeflow-core
3
+ Version: 3.8.0
4
+ Summary: Shared types for the LatticeFlow AI GO! ecosystem.
5
+ License-Expression: LicenseRef-Proprietary
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: pydantic==2.13.4
@@ -0,0 +1,203 @@
1
+ from __future__ import annotations
2
+
3
+ import inspect
4
+ import os
5
+ import shutil
6
+ import subprocess # nosec: B404 Used for build only.
7
+ import sys
8
+ from pathlib import Path
9
+ from typing import Any
10
+
11
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
12
+ from hatchling.metadata.plugin.interface import MetadataHookInterface
13
+
14
+
15
+ LOG_FILE_PATH = Path("build.log")
16
+
17
+
18
+ # ---------------------------------------------------------------------------
19
+ # Logging helpers (same pattern as openapi/assessment and assessment_sdk)
20
+ # ---------------------------------------------------------------------------
21
+
22
+
23
+ def build_log(messages: list[str], nesting_level: int = 1) -> None:
24
+ frame = inspect.currentframe()
25
+ if nesting_level == 1:
26
+ caller_name = (
27
+ frame.f_back.f_code.co_name if frame and frame.f_back else "unknown"
28
+ )
29
+ elif nesting_level == 2:
30
+ caller_name = (
31
+ frame.f_back.f_back.f_code.co_name
32
+ if frame and frame.f_back and frame.f_back.f_back
33
+ else "unknown"
34
+ )
35
+ else:
36
+ raise ValueError(
37
+ f"Invalid nesting level for build_log (provided {nesting_level})"
38
+ )
39
+ LOG_FILE_PATH.parent.mkdir(parents=True, exist_ok=True)
40
+ with LOG_FILE_PATH.open("a", encoding="utf-8") as log:
41
+ log.write("*" * 100 + "\n")
42
+ for message in messages:
43
+ log.write(f"[build] [{caller_name}]: {message}\n")
44
+ log.write("*" * 100 + "\n\n")
45
+
46
+
47
+ def lowercase_first_letter(string: str) -> str:
48
+ return string[0].lower() + string[1:] if string else string
49
+
50
+
51
+ def run_subprocess_with_log_and_error_handling(
52
+ subprocess_descriptive_message: str,
53
+ commands: list[str],
54
+ cwd: str | None = None,
55
+ env: subprocess._ENV | None = None,
56
+ ) -> None:
57
+ build_log([subprocess_descriptive_message], nesting_level=2)
58
+ result = subprocess.run(
59
+ args=commands,
60
+ cwd=cwd,
61
+ check=False,
62
+ capture_output=True,
63
+ text=True,
64
+ env=env, # nosec B603
65
+ shell=sys.platform == "win32",
66
+ )
67
+
68
+ if result.returncode == 0:
69
+ build_log(
70
+ [
71
+ f"Finished {lowercase_first_letter(subprocess_descriptive_message)}:",
72
+ f"[stdout] = {result.stdout}",
73
+ ],
74
+ nesting_level=2,
75
+ )
76
+ else:
77
+ build_log(
78
+ [
79
+ f"Failed while {lowercase_first_letter(subprocess_descriptive_message)}:",
80
+ f"[status code] = {result.returncode}",
81
+ f"[stdout] = {result.stdout}",
82
+ f"[stderr] = {result.stderr}",
83
+ ],
84
+ nesting_level=2,
85
+ )
86
+ raise RuntimeError(
87
+ f"Build failed! See {LOG_FILE_PATH.absolute()} for more information."
88
+ )
89
+
90
+
91
+ class JSONMetaDataHook(MetadataHookInterface):
92
+ """Set the package version from the ``LF_VERSION`` environment variable.
93
+
94
+ Same mechanism as the SDK: at release time ``LF_VERSION`` is set in CI
95
+ (e.g. ``LF_VERSION=0.40.0``). During development, defaults to ``0.0.0dev``.
96
+ """
97
+
98
+ def update(self, metadata: dict[str, Any]) -> None:
99
+ metadata["version"] = os.environ.get("LF_VERSION", "0.0.0dev")
100
+
101
+
102
+ # ---------------------------------------------------------------------------
103
+ # Vendoring bindings
104
+ # ---------------------------------------------------------------------------
105
+
106
+
107
+ def _vendor_bindings(
108
+ *, source_root: Path, bindings_subpath: str, destination: Path
109
+ ) -> None:
110
+ """Build an OpenAPI bindings package and copy the output into core.
111
+
112
+ Args:
113
+ source_root: Path to the OpenAPI package directory
114
+ (e.g. ``../openapi/assessment``).
115
+ bindings_subpath: Relative path under ``<source_root>/latticeflow/bindings/``
116
+ where the build hook places the generated files
117
+ (e.g. ``"assessment"`` or ``"open_responses"``).
118
+ destination: Where to copy the generated ``.py`` files inside core
119
+ (e.g. ``latticeflow/core/dtypes/_assessment``).
120
+ """
121
+ label = source_root.name # "assessment" or "open_responses"
122
+
123
+ build_log([f"Building {label} bindings from OpenAPI spec..."])
124
+ run_subprocess_with_log_and_error_handling(
125
+ f"Building {label} bindings from OpenAPI spec",
126
+ [sys.executable, "-m", "hatchling", "build", "--target", "wheel"],
127
+ cwd=str(source_root),
128
+ )
129
+
130
+ src = source_root / "latticeflow" / "bindings" / bindings_subpath
131
+ build_log([f"Copying {label} bindings from {src} to {destination}..."])
132
+
133
+ if destination.exists():
134
+ shutil.rmtree(destination)
135
+ destination.mkdir(parents=True, exist_ok=True)
136
+
137
+ for filepath in src.iterdir():
138
+ if filepath.is_file() and filepath.suffix == ".py":
139
+ shutil.copy2(filepath, destination / filepath.name)
140
+
141
+ (destination / "__init__.py").touch()
142
+
143
+
144
+ # ---------------------------------------------------------------------------
145
+ # Formatting
146
+ # ---------------------------------------------------------------------------
147
+
148
+
149
+ def format_vendored_code() -> None:
150
+ """Run ruff format on all vendored code.
151
+
152
+ Only formatting is applied -- linting (ruff check) is skipped because the
153
+ auto-generated binding code triggers style rules (e.g. D200) that are not
154
+ worth fixing in vendored output.
155
+ """
156
+ targets = [
157
+ "latticeflow/core/dtypes/_assessment",
158
+ "latticeflow/core/dtypes/_open_responses",
159
+ ]
160
+ for target in targets:
161
+ if Path(target).exists():
162
+ # Use --isolated to skip config discovery. The project ruff.toml
163
+ # excludes these vendored directories and extends a parent config
164
+ # that may not exist in all build environments (e.g. Docker).
165
+ run_subprocess_with_log_and_error_handling(
166
+ f"Formatting vendored code in {target}",
167
+ ["ruff", "format", "--isolated", target],
168
+ )
169
+
170
+
171
+ # ---------------------------------------------------------------------------
172
+ # Build hook
173
+ # ---------------------------------------------------------------------------
174
+
175
+
176
+ class CustomHook(BuildHookInterface):
177
+ """Custom build hook that vendors bindings at build/install time."""
178
+
179
+ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
180
+ if self.target_name not in ["wheel", "sdist"]:
181
+ return
182
+
183
+ # Create PEP 561 marker.
184
+ py_typed = Path("latticeflow/core/py.typed")
185
+ py_typed.parent.mkdir(parents=True, exist_ok=True)
186
+ py_typed.touch()
187
+
188
+ _vendor_bindings(
189
+ source_root=Path("../openapi/assessment"),
190
+ bindings_subpath="assessment",
191
+ destination=Path("latticeflow/core/dtypes/_assessment"),
192
+ )
193
+ _vendor_bindings(
194
+ source_root=Path("../openapi/open_responses"),
195
+ bindings_subpath="open_responses",
196
+ destination=Path("latticeflow/core/dtypes/_open_responses"),
197
+ )
198
+ format_vendored_code()
199
+
200
+ def finalize(
201
+ self, version: str, build_data: dict[str, Any], artifact_path: str
202
+ ) -> None:
203
+ LOG_FILE_PATH.unlink(missing_ok=True)
File without changes