feat(packaging): rewrite all imports from aignostics.* to aignostics_sdk.* [PYSDK-136]#657
Open
ari-nz wants to merge 4 commits into
Open
feat(packaging): rewrite all imports from aignostics.* to aignostics_sdk.* [PYSDK-136]#657ari-nz wants to merge 4 commits into
ari-nz wants to merge 4 commits into
Conversation
…sdk.*
- Mechanically rewrites 206 import statements across 91 files in
packages/aignostics-sdk/, packages/aignostics/, and tests/ so that
platform and utils references point at the new aignostics_sdk package
- Fixes two classes of non-obvious imports missed by naive sed:
* from ..utils import (relative two-level imports in heavy modules)
* from .utils.boot import boot (relative import in aignostics __init__)
- Restores aignostics.constants imports where heavy constants
(WINDOW_TITLE, HETA_APPLICATION_ID, etc.) live, since aignostics_sdk.constants
only carries the slim subset (INTERNAL_ORGS)
- Patches utils/_constants.py to preserve backward compat:
* __project_name__ = "aignostics" (keeps ~/.aignostics token cache
and AIGNOSTICS_* env-var prefix)
* _package_name derives from __name__.split(".")[0] = "aignostics_sdk"
* All three importlib.metadata calls now use _package_name so they
resolve against the correct installed distribution
- 900 tests collect successfully after the rewrite (0 collection errors)
- PYSDK-137 (slim CLI) and PYSDK-141 (tests) build on top of this change
…_sdk.platform._sdk_metadata
…d by initial sweep
…rce migration - Add packages/aignostics/src/aignostics/wsi/_pydicom_handler.py and packages/aignostics/src/aignostics/notebook/_notebook.py to ignore list (both were previously ignored under src/ but moved in PYSDK-135) - Exclude examples/ from pyright (pre-existing errors from before the split) - Remove stale extraPaths pointing at old src/ layout
There was a problem hiding this comment.
Pull request overview
Rewrites imports across the repository so that platform/utils references resolve to the new slim aignostics_sdk package, while keeping select heavy constants sourced from the full aignostics package. It also adjusts runtime metadata resolution and Pyright configuration to match the new packages layout.
Changes:
- массовый rewrite
from aignostics.*→from aignostics_sdk.*across source + tests - backward-compat tweak in
aignostics_sdk.utils._constantsto preserveAIGNOSTICS_*+~/.aignostics/while querying package metadata from the installed SDK distribution - updates
pyrightconfig.jsonexcludes/paths for the newpackages/layout
Reviewed changes
Copilot reviewed 110 out of 110 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/resources/mcp_dummy_plugin/src/mcp_dummy_plugin/_nav.py | Update dummy plugin imports to aignostics_sdk.utils. |
| tests/main.py | Switch GUI runner import to aignostics_sdk.utils. |
| tests/aignostics/wsi/service_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/wsi/cli_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/utils/user_agent_test.py | Switch user-agent import to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/utils/settings_test.py | Switch settings import to aignostics_sdk.utils._settings. |
| tests/aignostics/utils/service_test.py | Switch health/service imports to aignostics_sdk.utils. |
| tests/aignostics/utils/sentry_test.py | Switch sentry imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/utils/plugin_test.py | Switch DI/nav imports to aignostics_sdk.utils. |
| tests/aignostics/utils/mcp_test.py | Switch MCP imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/utils/log_test.py | Switch logging imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/utils/health_test.py | Switch health model import to aignostics_sdk. |
| tests/aignostics/utils/gui_test.py | Switch GUI imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/utils/fs_test.py | Switch FS imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/utils/di_test.py | Switch DI/CLI imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/utils/constants_test.py | Switch version imports to aignostics_sdk.utils. |
| tests/aignostics/utils/console_test.py | Switch console import to aignostics_sdk.utils._console. |
| tests/aignostics/utils/cli_test.py | Switch prepare_cli import to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/system/service_test.py | Switch process-info import to aignostics_sdk.utils._process. |
| tests/aignostics/system/gui_test.py | Switch __project_name__ import to aignostics_sdk.utils. |
| tests/aignostics/system/cli_test.py | Switch __project_name__/Health imports to aignostics_sdk.utils. |
| tests/aignostics/qupath/gui_test.py | Switch __project_name__ import to aignostics_sdk.utils. |
| tests/aignostics/qupath/conftest.py | Import-order tweak (no semantic change). |
| tests/aignostics/qupath/cli_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/platform/utils_test.py | Switch platform utils imports to aignostics_sdk.platform. |
| tests/aignostics/platform/settings_test.py | Switch platform/settings imports to aignostics_sdk (but module-reload string still needs updating). |
| tests/aignostics/platform/service_test.py | Switch service import to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/sdk_metadata_test.py | Switch SDK-metadata imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/resources/runs_test.py | Switch runs resource imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/resources/resource_utils_test.py | Switch pagination import to aignostics_sdk. |
| tests/aignostics/platform/resources/applications_test.py | Switch applications resource imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/nocache_test.py | Switch client/resource imports to aignostics_sdk.platform. |
| tests/aignostics/platform/e2e_test.py | Switch public platform API imports to aignostics_sdk. |
| tests/aignostics/platform/conftest.py | Switch platform fixtures to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/client_token_provider_test.py | Switch token-provider imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/client_pooling_test.py | Switch client import to aignostics_sdk.platform._client. |
| tests/aignostics/platform/client_me_retry_test.py | Switch client import to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/client_cache_test.py | Switch client/cache imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/cli_test.py | Switch platform model imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/platform/authentication_test.py | Switch auth imports to aignostics_sdk (but patch targets still need updating). |
| tests/aignostics/notebook/service_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/dataset/service_test.py | Whitespace-only cleanup. |
| tests/aignostics/dataset/cli_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/cli_test.py | Switch version imports + GUI monkeypatch import to aignostics_sdk.utils. |
| tests/aignostics/bucket/settings_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/bucket/service_test.py | Whitespace-only cleanup. |
| tests/aignostics/bucket/gui_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/bucket/cli_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/application/utils_test.py | Switch platform model imports to aignostics_sdk.platform. |
| tests/aignostics/application/service_test.py | Switch platform model imports to aignostics_sdk.platform. |
| tests/aignostics/application/gui_test.py | Import-order tweak (no semantic change). |
| tests/aignostics/application/download_test.py | Switch platform model imports to aignostics_sdk.platform. |
| tests/aignostics/application/cli_test.py | Switch platform/utils imports to aignostics_sdk. |
| tests/aignostics/application/cli_pipeline_validation_test.py | Import-order tweak (no semantic change). |
| src/aignostics.py | Switch boot/gui_run import to aignostics_sdk.utils. |
| runner/gui_watch.py | Switch gui_run import to aignostics_sdk.utils. |
| pyrightconfig.json | Update Pyright exclude paths; drop extraPaths; ignore examples. |
| packages/aignostics/src/aignostics/wsi/_utils.py | Switch console import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/wsi/_service.py | Switch BaseService/Health import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/wsi/_pydicom_handler.py | Switch console import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/wsi/_gui.py | Switch BasePageBuilder import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/wsi/_cli.py | Switch console import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/third_party/idc_index.py | Switch subprocess flags import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/system/_settings.py | Replace relative utils import with aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/system/_service.py | Replace relative utils import with aignostics_sdk.utils (plus import reordering). |
| packages/aignostics/src/aignostics/system/_gui.py | Switch BasePageBuilder/BaseService/locate_subclasses to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/system/_cli.py | Switch console/gui_run imports to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/qupath/_settings.py | Replace relative utils import with aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/qupath/_service.py | Switch BaseService/Health/etc. to aignostics_sdk.utils (import reordering). |
| packages/aignostics/src/aignostics/qupath/_gui.py | Switch BasePageBuilder import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/qupath/_cli.py | Switch console import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/notebook/_service.py | Switch BaseService/Health/etc. to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/notebook/_notebook.py | Switch user data dir import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/notebook/_gui.py | Switch BasePageBuilder/user data dir imports to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/gui/_theme.py | Switch BasePageBuilder import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/gui/_frame.py | Switch version/user-data/platform imports to aignostics_sdk. |
| packages/aignostics/src/aignostics/gui/_error.py | Switch BasePageBuilder import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/dataset/_service.py | Switch platform signed-url + utils imports to aignostics_sdk. |
| packages/aignostics/src/aignostics/dataset/_gui.py | Switch BasePageBuilder/file picker/user data dir imports to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/dataset/_cli.py | Switch console/user data dir imports to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/constants.py | Switch __version__ source to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/cli.py | Switch CLI utilities imports to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/bucket/_settings.py | Replace relative utils import with aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/bucket/_service.py | Switch platform/service utils imports to aignostics_sdk. |
| packages/aignostics/src/aignostics/bucket/_gui.py | Switch BasePageBuilder/file picker/user data dir imports to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/bucket/_cli.py | Switch console/user data dir imports to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/application/_utils.py | Switch platform + console imports to aignostics_sdk. |
| packages/aignostics/src/aignostics/application/_settings.py | Replace relative utils import with aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/application/_service.py | Switch platform/service utils imports to aignostics_sdk (import reordering). |
| packages/aignostics/src/aignostics/application/_models.py | Switch platform model imports to aignostics_sdk.platform. |
| packages/aignostics/src/aignostics/application/_gui/_utils.py | Switch run/item enum imports to aignostics_sdk.platform. |
| packages/aignostics/src/aignostics/application/_gui/_page_builder.py | Switch BasePageBuilder import to aignostics_sdk.utils. |
| packages/aignostics/src/aignostics/application/_gui/_page_application_run_describe.py | Switch platform/utils types to aignostics_sdk; adjust TYPE_CHECKING import. |
| packages/aignostics/src/aignostics/application/_gui/_page_application_describe.py | Switch platform/utils types to aignostics_sdk (import reordering). |
| packages/aignostics/src/aignostics/application/_gui/_frame.py | Import-order tweak (no semantic change). |
| packages/aignostics/src/aignostics/application/_download.py | Switch platform/utils imports to aignostics_sdk. |
| packages/aignostics/src/aignostics/application/_cli.py | Switch platform/utils imports to aignostics_sdk (import reordering). |
| packages/aignostics/src/aignostics/init.py | Switch boot import to aignostics_sdk.utils.boot. |
| packages/aignostics-sdk/src/aignostics_sdk/utils/_mcp.py | Update docstring example import to aignostics_sdk.utils. |
| packages/aignostics-sdk/src/aignostics_sdk/utils/_fs.py | Import reordering only. |
| packages/aignostics-sdk/src/aignostics_sdk/utils/_constants.py | Hardcode __project_name__ for backward compat; query metadata via SDK package name. |
| packages/aignostics-sdk/src/aignostics_sdk/platform/resources/runs.py | Rewrite internal imports to aignostics_sdk.platform and aignostics_sdk.utils. |
| packages/aignostics-sdk/src/aignostics_sdk/platform/resources/applications.py | Rewrite internal imports to aignostics_sdk.platform and aignostics_sdk.utils. |
| packages/aignostics-sdk/src/aignostics_sdk/platform/_settings.py | Switch utils imports to aignostics_sdk.utils. |
| packages/aignostics-sdk/src/aignostics_sdk/platform/_service.py | Switch constants/utils imports to aignostics_sdk.*. |
| packages/aignostics-sdk/src/aignostics_sdk/platform/_sdk_metadata.py | Switch user_agent + client import to aignostics_sdk. |
| packages/aignostics-sdk/src/aignostics_sdk/platform/_client.py | Switch internal platform/utils imports to aignostics_sdk. |
| packages/aignostics-sdk/src/aignostics_sdk/platform/_cli.py | Switch console import to aignostics_sdk.utils. |
| packages/aignostics-sdk/src/aignostics_sdk/platform/_authentication.py | Switch internal settings/messages/api imports to aignostics_sdk.platform. |
| examples/notebook.py | Update example import path to aignostics_sdk (but referenced class name needs correction). |
Comments suppressed due to low confidence (4)
tests/aignostics/utils/log_test.py:111
logging_initializeis imported fromaignostics_sdk.utils._log, but the patched target still points toaignostics.utils._log.load_settings, so the mock won’t affect the function under test. Update the patch target toaignostics_sdk.utils._log.load_settings(and any otheraignostics.utils._log.*patch targets in this file) to keep the test effective.
tests/aignostics/utils/gui_test.py:13- This file now imports GUI helpers from
aignostics_sdk.utils._gui, but themock.patch(...)targets below still referenceaignostics.utils._gui.*, so they won’t patch the module actually used by the tests. Update the patch targets toaignostics_sdk.utils._gui.*to avoid false positives/negatives in these tests.
examples/notebook.py:235 ApplicationRundoes not appear to exist inaignostics_sdk.platform.resources.runs(the resource class isRun). Update the example code (and surrounding narrative) to import/use the correct class (e.g.,Run.for_run_id(...)) so the notebook example works.
from aignostics_sdk.platform.resources.runs import ApplicationRun
application_run = ApplicationRun.for_run_id("<run_id>")
# download
download_folder = "/tmp/"
application_run.download_to_folder(download_folder)
tests/aignostics/utils/fs_test.py:12
- This file now imports filesystem helpers from
aignostics_sdk.utils._fs, but many tests still patchaignostics.utils._fs.*(e.g.,platformdirs.user_data_dir,__project_name__). Those patches won’t affect the module under test; update patch targets toaignostics_sdk.utils._fs.*.
Comment on lines
11
to
+24
| @@ -23,6 +21,7 @@ | |||
| _validate_url_scheme, | |||
| sentry_initialize, | |||
| ) | |||
| from pydantic import SecretStr | |||
Comment on lines
+7
to
12
| from aignostics_sdk.utils._cli import prepare_cli | ||
| from typer.models import CommandInfo, TyperInfo | ||
|
|
||
| from aignostics.utils._cli import prepare_cli | ||
|
|
||
| # Constants to avoid duplication | ||
| LOCATE_IMPLEMENTATIONS_PATH = "aignostics.utils._cli.locate_implementations" | ||
| TEST_EPILOG = "Test Epilog" |
Comment on lines
+12
to
+18
| from aignostics_sdk.utils._cli import ( | ||
| _add_epilog_recursively, | ||
| _no_args_is_help_recursively, | ||
| prepare_cli, | ||
| ) | ||
| from aignostics.utils._constants import __project_name__ | ||
| from aignostics.utils._di import ( | ||
| from aignostics_sdk.utils._constants import __project_name__ | ||
| from aignostics_sdk.utils._di import ( |
Comment on lines
+7
to
11
| from aignostics_sdk.platform._service import Service, UserInfo | ||
| from aignostics_sdk.utils import Health | ||
|
|
||
| _PATCH_AUTH_GETTER = "aignostics.platform._service.get_token" | ||
| _PATCH_HTTPX_ASYNC_CLIENT = "aignostics.platform._service.httpx.AsyncClient" |
Comment on lines
16
to
26
| @@ -27,12 +24,14 @@ | |||
| remove_cached_token, | |||
| verify_and_decode_token, | |||
| ) | |||
Comment on lines
+10
to
+17
| from aignostics_sdk.utils import ( | ||
| MCP_SERVER_NAME, | ||
| discover_plugin_packages, | ||
| mcp_create_server, | ||
| mcp_discover_servers, | ||
| mcp_list_tools, | ||
| ) | ||
| from aignostics.utils._di import _implementation_cache | ||
| from aignostics_sdk.utils._di import _implementation_cache |
Comment on lines
6
to
8
| import pytest | ||
|
|
||
| from aignostics.utils._user_agent import user_agent | ||
| from aignostics_sdk.utils._user_agent import user_agent | ||
|
|
Comment on lines
8
to
10
| import pytest | ||
| from aignostics_sdk.platform._client import Client | ||
| from aignx.codegen.exceptions import ServiceException |
Comment on lines
+12
to
15
| from aignostics_sdk.platform._api import _AuthenticatedApi | ||
| from aignostics_sdk.platform.resources.runs import LIST_APPLICATION_RUNS_MAX_PAGE_SIZE, Artifact, Run, Runs | ||
| from aignostics_sdk.platform.resources.utils import PAGE_SIZE | ||
| from aignx.codegen.exceptions import ApiException, NotFoundException, ServiceException |
Comment on lines
+14
to
+22
| from aignostics_sdk.platform._api import _AuthenticatedApi | ||
| from aignostics_sdk.platform._operation_cache import operation_cache_clear | ||
| from aignostics_sdk.platform.resources.applications import ( | ||
| Applications, | ||
| ApplicationVersionDocument, | ||
| Documents, | ||
| Versions, | ||
| ) | ||
| from aignostics.platform.resources.utils import PAGE_SIZE | ||
| from aignostics_sdk.platform.resources.utils import PAGE_SIZE |
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release Train — PYSDK-133
Summary
platformandutilsreferences resolve to the newaignostics_sdkpackagefrom ..utils import(two-level relative imports in heavy modules) andfrom .utils.boot import boot(relative import in aignostics__init__.py)aignostics.constantsimports in files that need heavy constants (WINDOW_TITLE,HETA_APPLICATION_ID, etc.) which live in the fullaignosticspackage, not the slimaignostics_sdk.constantsutils/_constants.pyfor backward compatibility:__project_name__ = "aignostics"— preserves~/.aignostics/token cache andAIGNOSTICS_*env-var prefix_package_name = __name__.split(".")[0]→"aignostics_sdk"— used for all threeimportlib.metadatacalls (version, Project-URLs, Author-email) so they resolve against the correct installed distributionpyrightconfig.jsonignore paths to reflect the newpackages/layout from PYSDK-135Notable decisions
__project_name__ = "aignostics"hardcodedaignostics.constantsimports preservedWINDOW_TITLE,HETA_APPLICATION_ID, etc.) live in the fullaignosticspackage, not inaignostics_sdk.constantsexamples/added to pyright ignorefrom aignostics import platformerrors since PYSDK-135 (the public API hasn't been wired up yet)Dependencies
Test plan
make lint) — verified locally before pushuv run pytest tests/ --collect-only -q)make test_unit)