Skip to content

feat(packaging): rewrite all imports from aignostics.* to aignostics_sdk.* [PYSDK-136]#657

Open
ari-nz wants to merge 4 commits into
feat/PYSDK-135/source-migrationfrom
feat/PYSDK-136/import-rewrite
Open

feat(packaging): rewrite all imports from aignostics.* to aignostics_sdk.* [PYSDK-136]#657
ari-nz wants to merge 4 commits into
feat/PYSDK-135/source-migrationfrom
feat/PYSDK-136/import-rewrite

Conversation

@ari-nz
Copy link
Copy Markdown
Collaborator

@ari-nz ari-nz commented May 28, 2026

Release Train — PYSDK-133

Verify wiring on the integration branch first: #661 (draft, targets main)

Step PR Jira Phase Notes
1 #653 PYSDK-134 Workspace scaffolding Merge first — gates everything below
2a #656 PYSDK-135 Source migration After #653
2b #655 PYSDK-138 Dependency split After #653, parallel with 2a
2c #654 PYSDK-139 Tooling updates After #653, parallel with 2a
3 #657 PYSDK-136 Import rewrite After #656
4a #658 PYSDK-137 Slim CLI After #657
4b #659 PYSDK-141 Tests After #657, parallel with 4a
#651 PYSDK-140 CI/CD pipeline Independent — merge any time
#652 PYSDK-142 Docs & migration Independent — merge any time

Retargeting: each PR currently targets its predecessor branch. After the predecessor merges into feat/PYSDK-133/python-sdk-slim, retarget this PR to feat/PYSDK-133/python-sdk-slim before merging it.


This PR — Step 3: Merge after #656 (source migration). Retarget to feat/PYSDK-133/python-sdk-slim first. #658 (slim CLI) and #659 (tests) depend on this.

Summary

  • Rewrites 206 import statements across 91 source files (packages/aignostics-sdk/, packages/aignostics/, tests/, runner/, src/, examples/) so that platform and utils references resolve to the new aignostics_sdk package
  • Fixes two non-trivial import forms missed by naive sed: from ..utils import (two-level relative imports in heavy modules) and from .utils.boot import boot (relative import in aignostics __init__.py)
  • Restores aignostics.constants imports in files that need heavy constants (WINDOW_TITLE, HETA_APPLICATION_ID, etc.) which live in the full aignostics package, not the slim aignostics_sdk.constants
  • Patches utils/_constants.py for backward compatibility:
    • __project_name__ = "aignostics" — preserves ~/.aignostics/ token cache and AIGNOSTICS_* env-var prefix
    • _package_name = __name__.split(".")[0]"aignostics_sdk" — used for all three importlib.metadata calls (version, Project-URLs, Author-email) so they resolve against the correct installed distribution
  • Updates pyrightconfig.json ignore paths to reflect the new packages/ layout from PYSDK-135
  • 900 tests collect successfully with 0 collection errors after the rewrite

Notable decisions

Decision Rationale
__project_name__ = "aignostics" hardcoded Preserves token cache location and env var prefix for users; deliberate migration deferred — see TODO(PYSDK-136)
aignostics.constants imports preserved Those constants (WINDOW_TITLE, HETA_APPLICATION_ID, etc.) live in the full aignostics package, not in aignostics_sdk.constants
examples/ added to pyright ignore These had pre-existing from aignostics import platform errors since PYSDK-135 (the public API hasn't been wired up yet)

Dependencies

  • Builds on top of PYSDK-135 (source migration)
  • PYSDK-137 (slim CLI) and PYSDK-141 (tests reorganization) build on top of this change

Test plan

  • Lint passes (make lint) — verified locally before push
  • 900 tests collect with 0 errors (uv run pytest tests/ --collect-only -q)
  • Unit tests pass (make test_unit)

ari-nz added 4 commits May 28, 2026 13:13
…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
…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
@ari-nz ari-nz requested a review from a team as a code owner May 28, 2026 11:22
Copilot AI review requested due to automatic review settings May 28, 2026 11:22
@ari-nz ari-nz added the skip:test:long_running Skip long-running tests (≥5min) label May 28, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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._constants to preserve AIGNOSTICS_* + ~/.aignostics/ while querying package metadata from the installed SDK distribution
  • updates pyrightconfig.json excludes/paths for the new packages/ 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_initialize is imported from aignostics_sdk.utils._log, but the patched target still points to aignostics.utils._log.load_settings, so the mock won’t affect the function under test. Update the patch target to aignostics_sdk.utils._log.load_settings (and any other aignostics.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 the mock.patch(...) targets below still reference aignostics.utils._gui.*, so they won’t patch the module actually used by the tests. Update the patch targets to aignostics_sdk.utils._gui.* to avoid false positives/negatives in these tests.
    examples/notebook.py:235
  • ApplicationRun does not appear to exist in aignostics_sdk.platform.resources.runs (the resource class is Run). 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 patch aignostics.utils._fs.* (e.g., platformdirs.user_data_dir, __project_name__). Those patches won’t affect the module under test; update patch targets to aignostics_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip:test:long_running Skip long-running tests (≥5min)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants