Skip to content

chore: promote experimental APIs to main API surface - #48

Merged
yjzhang merged 13 commits into
mainfrom
feat/promote-experimental-apis
Aug 14, 2026
Merged

chore: promote experimental APIs to main API surface#48
yjzhang merged 13 commits into
mainfrom
feat/promote-experimental-apis

Conversation

@SkyeAv

@SkyeAv SkyeAv commented Aug 6, 2026

Copy link
Copy Markdown
Member

Promotes the former TCT.experimental developer-friendly finder wrappers into the main API surface, exported through the existing __all__ + star-import pattern.

What changed

  • Finder entry points live in their submodules: pathfinder in TCT/TCT_pathfinder.py and neighborhood_finder in TCT/TCT_neighborhood_finder.py, re-exported from TCT/TCT.py (repo convention: finder logic in its submodule, public names imported back into TCT).
  • Single neighborhood_finder: the legacy low-level neighborhood_finder / neighborhood_finder_multiple_inputs wrappers are removed; the developer-friendly neighborhood_finder (handles single + multiple inputs via a list, returns a FinderResult) is now the only implementation, defined directly under its public name — no _neighborhood_finder alias.
  • Shared infrastructure stays in TCT/TCT.py: the result/resource dataclasses (FinderResult, ResolvedNode, TranslatorResources), get_translator_resources / clear_translator_resource_cache, and the node/category/resource helpers. The legacy Path_finder and Neighborhood_finder entry points are removed.
  • Internal caller migrated: TCT_network_annotator.network_annotator now uses the new neighborhood_finder API (one query+parse per gene via FinderResult.raw), replacing the old call-then-parse_results_for_neighborhood_finder pair and dropping the unused ranked tuple.
  • TCT/experimental.py: deleted.
  • Tests: tests/test_experimental.pytests/test_finder_api.py (11 tests), with the finder-test monkeypatches retargeted at the submodules; helper tests unchanged.
  • Notebooks: quick-start sections for the promoted APIs added to Path_finder, Neighborhood_finder, and Neighborhood_finder_multiple_nodes; the detailed neighborhood-workflow cells in Neighborhood_extender, Neighborhood_finder, Connecting_userAPI, and Neighborhood_finder_multiple_nodes migrated to the new neighborhood_finder API (legacy call + re-parse collapsed into finder_result.raw); all four re-executed end-to-end against Translator endpoints so the migrated cells carry live outputs. Experimental_API_tutorial.ipynb deleted.
  • Docs/README: experimental wording removed; promoted wrappers mentioned in README and docs intro.
  • CI: reverted the ci: harden sphinx and codespell workflows commit so this PR does not bundle unrelated CI hardening.
  • pyproject.toml intentionally untouched (no version bump).

Verification

  • uv run pytest: finder API tests pass (11/11); the only failures are the pre-existing tests/test_main.py cases that require the optional fastmcp (MCP) extra, unrelated to this change.
  • ruff check: no new findings vs main baseline (remaining findings are pre-existing in untouched code).
  • Neighborhood notebooks (Neighborhood_finder, Neighborhood_finder_multiple_nodes, Neighborhood_extender, Connecting_userAPI) re-executed successfully; migrated neighborhood_finder cells carry live outputs.
  • Live smoke: get_translator_resources, pathfinder('asthma','albuterol',['Gene','Protein']), single + multi-input neighborhood_finder, refresh=True, and clear_translator_resource_cache all ran successfully against Translator endpoints.
  • CODE_REVIEWER pass completed; findings fixed in an earlier commit.

Known limitation

Connecting_userAPI.ipynb is executed with errors allowed: its cell hitting the external user-API endpoint (amlkg.systemsbiology.org:9990) fails with an SSL error (endpoint currently unreachable), which is unrelated to this change. All other cells, including the migrated neighborhood_finder cell, execute successfully.

SkyeAv added 5 commits August 6, 2026 13:22
Move the former TCT.experimental wrappers (pathfinder,
neighborhood_finder, resource cache, result dataclasses) into
TCT/TCT.py, replacing the legacy Path_finder and Neighborhood_finder
entry points. Delete the unused low-level TCT_pathfinder.pathfinder
and rename tests/test_experimental.py to tests/test_finder_api.py.
Fold the experimental tutorial content into Path_finder,
Neighborhood_finder, Neighborhood_finder_multiple_nodes, and
Connecting_userAPI notebooks; delete the experimental tutorial
notebook and re-execute notebooks so outputs reflect the new API.

Path_finder, Neighborhood_finder, and
Neighborhood_finder_multiple_nodes executed cleanly against live
Translator endpoints. Connecting_userAPI could not be re-executed:
the external user-API endpoint (amlkg.systemsbiology.org:9990) is
unreachable (SSL error), so its cells keep the previously committed
outputs while the pathfinder call is updated to the new API.
Rewrite the Connecting_userAPI result cell to serialize
FinderResult.to_dict() instead of the deleted TCT.Path_finder dict
shape, drop the unused cache-clear import from the Path_finder
quick-start (notebook re-executed), and mention the promoted
pathfinder/neighborhood_finder wrappers in the docs intro.
Re-execution refreshed outputs on every cell, inflating the diff.
Restore the committed outputs/execution counts for cells this PR does
not modify; keep executed outputs only on the new quick-start cells and
the replaced legacy-call cells.
@SkyeAv
SkyeAv marked this pull request as ready for review August 6, 2026 21:01
SkyeAv added 3 commits August 7, 2026 12:18
- Add concurrency groups with cancel-in-progress so superseded runs
  auto-cancel instead of accumulating
- Bump setup-uv v3 -> v4 in codespell.yml to match main.yml
- Add docs/source/_static/ dir to fix Sphinx html_static_path warning
Move the promoted `pathfinder` and `neighborhood_finder` functions out of
`TCT/TCT.py` into `TCT/TCT_pathfinder.py` and `TCT/TCT_neighborhood_finder.py`,
following the repo convention of keeping finder logic in its submodule and
importing/re-exporting the public names from `TCT`. The shared infrastructure
stays in `TCT.py`: the result/resource dataclasses (`FinderResult`,
`ResolvedNode`, `TranslatorResources`), `get_translator_resources` /
`clear_translator_resource_cache`, and the node/category/resource helpers.

`neighborhood_finder` is defined as `_neighborhood_finder` in its submodule
(to avoid colliding with the existing low-level
`TCT_neighborhood_finder.neighborhood_finder` used by the network annotator
and notebooks) and re-exported under its public name from `TCT.py`, so no
legacy caller changes. The submodule re-exports sit at the end of `TCT.py`
(after the helpers are defined) to avoid a circular import. Retarget the
finder-test monkeypatches at the submodules; helper tests are unchanged.
@SkyeAv

SkyeAv commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

Update: restructured so the finder entry points are not all dumped in TCT.py, and reverted the CI hardening so it isn't bundled with this PR.

Two new commits:

  1. Revert "ci: harden sphinx and codespell workflows" — drops the unrelated CI changes (codespell/sphinx workflow hardening). CI may now flag codespell/sphinx; that's intentional for this PR.
  2. refactor: relocate finder entry points into their submodules — moves the code out of TCT.py using the repo's existing conventions:
    • pathfinderTCT/TCT_pathfinder.py
    • neighborhood_finderTCT/TCT_neighborhood_finder.py (as _neighborhood_finder, re-exported under its public name to avoid colliding with the existing low-level neighborhood_finder used by the network annotator + notebooks — no legacy caller changes)
    • Stays in TCT.py: get_translator_resources, clear_translator_resource_cache, and the result/resource dataclasses + shared helpers (_resolve_node, _get_resources, _build_finder_result, etc.)
    • Submodule re-exports sit at the end of TCT.py (after the helpers are defined) to avoid a circular import; finder-test monkeypatches retargeted at the submodules, helper tests unchanged.

Verified: uv run pytest tests/test_finder_api.py → 11/11 pass; full suite green except the pre-existing tests/test_main.py failures (missing optional fastmcp extra). ruff check introduces no new findings vs main.

… API

Drop the private `_neighborhood_finder` alias and the legacy low-level
`neighborhood_finder` / `neighborhood_finder_multiple_inputs` wrappers from
`TCT_neighborhood_finder`. The developer-friendly `neighborhood_finder`
(single + multiple inputs via a list) is now the only implementation, defined
directly under its public name and re-exported from `TCT` without aliasing.

Migrate TCT's internal caller `TCT_network_annotator.network_annotator` to the
new API: one query+parse per gene via `FinderResult.raw`, replacing the old
call-then-`parse_results_for_neighborhood_finder` pair (and dropping the unused
ranked tuple it never consumed).

Update the neighborhood notebooks (Neighborhood_extender, Neighborhood_finder,
Connecting_userAPI, Neighborhood_finder_multiple_nodes) to call the new API,
collapsing each legacy call + re-parse into a single call (`finder_result.raw`).
Outputs of the rewritten cells are cleared pending re-execution.
@SkyeAv

SkyeAv commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Update: collapsed to a single neighborhood_finder (no more _neighborhood_finder alias) and migrated TCT's internal caller to the new API. New commit c9042c6.

  • TCT_neighborhood_finder: removed the legacy low-level neighborhood_finder and neighborhood_finder_multiple_inputs wrappers; the promoted neighborhood_finder (single + multiple inputs via a list, returns FinderResult) is now the only implementation, under its public name. TCT.py re-exports it directly (from .TCT_neighborhood_finder import neighborhood_finder).
  • TCT_network_annotator.network_annotator (the internal caller): now uses the new API — one query+parse per gene via FinderResult.raw, replacing the old call-then-parse_results_for_neighborhood_finder pair (and dropping the ranked tuple it never consumed). Net −252 lines across the PR.
  • Notebooks: migrated the detailed neighborhood-workflow cells in Neighborhood_extender, Neighborhood_finder, Connecting_userAPI, and Neighborhood_finder_multiple_nodes to the new API (finder_result.raw). Outputs of the rewritten cells are cleared pending re-execution.

Verified: pytest finder tests 11/11 pass (only pre-existing fastmcp failures remain); ruff introduces no new findings; migrated cells parse cleanly; no stray references to the removed functions anywhere.

Notebook re-execution (to refresh outputs) is left as a follow-up — flag if you'd like me to re-run them against the Translator endpoints.

Re-run Neighborhood_finder, Neighborhood_finder_multiple_nodes,
Neighborhood_extender, and Connecting_userAPI end-to-end so the migrated
neighborhood_finder cells carry live outputs. Connecting_userAPI runs with
errors allowed; its only failure is the pre-existing SSL error on the external
user-API endpoint (amlkg.systemsbiology.org:9990), unrelated to the migration.
@SkyeAv

SkyeAv commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Re-executed the four neighborhood notebooks against the Translator endpoints (commit 9b7ff15) — the migrated neighborhood_finder cells now carry live outputs.

  • Neighborhood_finder, Neighborhood_finder_multiple_nodes, Neighborhood_extender: executed cleanly end-to-end.
  • Connecting_userAPI: executed with errors allowed. The only failure is the pre-existing SSL error on the external user-API endpoint (amlkg.systemsbiology.org:9990), unrelated to the migration; the migrated neighborhood_finder cell ran successfully.

Updated the PR description accordingly (removed the "pending re-execution" note).

@SkyeAv
SkyeAv requested a review from gloriachin August 12, 2026 21:56
SkyeAv and others added 3 commits August 14, 2026 14:05
* feat: isolate visualization dependencies into 'vision' extra group

* feat: isolate visualization dependencies into 'vision' extra group

* fix: make visualization extra valid and optional

* docs: keep visualization extra change focused
@yjzhang
yjzhang merged commit 06dfd77 into main Aug 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants