Repository navigation
feature/SOF-8000 Chore: API helpers of notebooks_utils imported from mat3ra.api_client.tools #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c50b7b5
58423d8
b9a30b6
f659f3a
81fc701
839586a
086b276
24d4c00
7ae0014
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,7 +67,7 @@ notebooks: | |
| - ipywidgets | ||
| - tabulate==0.9.0 | ||
| - mat3ra-utils | ||
| - mat3ra-api-client>=2026.11.4.post0 | ||
| - mat3ra-api-client[tools]>=2026.11.4.post0 | ||
| - name: dataframe | ||
| packages_pyodide: | ||
| - jinja2 | ||
|
|
@@ -80,11 +80,11 @@ notebooks: | |
| - emfs:/drive/packages/pydantic-2.7.1-py3-none-any.whl | ||
| - mat3ra-standata | ||
| - mat3ra-ide | ||
| - mat3ra-api-client>=2026.11.4.post0 | ||
| - mat3ra-api-client[tools]>=2026.11.4.post0 | ||
| - requests | ||
| - mat3ra-ade | ||
| - mat3ra-mode | ||
| - mat3ra-wode | ||
| - mat3ra-wode[tools] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
The version constraint cannot fix this for the releases checked. Before this dependency can work, a
|
||
| - mat3ra-prode | ||
| - name: torch | ||
| packages_pyodide: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,5 @@ | ||
| """File-based OIDC token cache storage.""" | ||
|
|
||
| import json | ||
| import os | ||
| from mat3ra.api_client.tools.auth.token import read, write | ||
|
|
||
| _FILE_PATH = os.path.join(os.path.expanduser("~"), ".mat3ra", "oidc_token_cache.json") | ||
|
|
||
|
|
||
| async def read() -> dict: | ||
| try: | ||
| with open(_FILE_PATH) as f: | ||
| return json.load(f) | ||
| except (FileNotFoundError, json.JSONDecodeError): | ||
| return {} | ||
|
|
||
|
|
||
| async def write(cache: dict) -> None: | ||
| os.makedirs(os.path.dirname(_FILE_PATH), exist_ok=True) | ||
| with open(_FILE_PATH, "w") as f: | ||
| json.dump(cache, f) | ||
| __all__ = ["read", "write"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,3 @@ | ||
| import json | ||
| import os | ||
| from mat3ra.ide.tools.cluster import get_cluster_name | ||
|
|
||
|
|
||
| def get_cluster_name(name: str = "cluster-001") -> str: | ||
| clusters = json.loads(os.environ.get("CLUSTERS", "[]") or "[]") | ||
| return clusters[0] if clusters else name | ||
| __all__ = ["get_cluster_name"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,8 @@ | ||
| def to_object_storage_input(cloud_file: dict) -> dict: | ||
| """ | ||
| Converts an upload record into an `object_storage` input item for a workflow IO unit. | ||
| from mat3ra.wode.tools.unit import to_object_storage_input as _to_object_storage_input | ||
|
|
||
| Args: | ||
| cloud_file (dict): A record returned by `client.files.upload` (mat3ra-api-client). | ||
|
|
||
| Returns: | ||
| dict: IO unit input item. The runner fetches it into the job's working directory under | ||
| `basename`, which is what makes the user script's relative paths resolve. | ||
| def to_object_storage_input(cloud_file: dict) -> dict: | ||
| """ | ||
| `to_object_storage_input` of mat3ra.wode.tools.unit, returning the IO unit input item as a dict. | ||
| """ | ||
| return { | ||
| "type": "object_storage", | ||
| "basename": cloud_file["key"].split("/")[-1], | ||
| "pathname": "", | ||
| "objectData": { | ||
| "NAME": cloud_file["key"], | ||
| "PROVIDER": cloud_file["provider"], | ||
| "CONTAINER": cloud_file["bucket"], | ||
| "REGION": cloud_file["region"], | ||
| }, | ||
| } | ||
| return _to_object_storage_input(cloud_file).model_dump(exclude_none=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require the release that contains the tools.
Both entries accept
2026.11.4.post0, whose published metadata has notoolsextra. Upstream PR#53adds that extra and the delegated modules. An environment with the older client can therefore satisfy this requirement but fail to import the notebook helpers. (pypi.org)After the upstream release, raise the minimum version here and in
pyproject.tomlto the first release that contains the tools.Also applies to: 83-83