-
-
Notifications
You must be signed in to change notification settings - Fork 4
zntrack mcp #929
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?
zntrack mcp #929
Changes from all commits
ddf8549
6ee4188
77bd046
6878d1e
4e369ee
f619534
351c91e
dab2447
ff9294f
8ce3475
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import logging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from zntrack import config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from zntrack import config, entrypoints | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
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. 🛠️ Refactor suggestion Add The Apply this diff to add it to the public API: __all__ = [
"params",
"deps",
"outs",
"plots",
"metrics",
"params_path",
"deps_path",
"outs_path",
"plots_path",
"metrics_path",
"Node",
"Project",
"nwd",
"from_rev",
"apply",
"add",
"field",
"FieldTypes",
"NOT_AVAILABLE",
"config",
+ "entrypoints",
]Or remove the unused import: -from zntrack import config, entrypoints
+from zntrack import config📝 Committable suggestion
Suggested change
Suggested change
🧰 Tools🪛 Ruff (0.12.2)5-5: (F401) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from zntrack.add import add | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from zntrack.apply import apply | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from zntrack.config import NOT_AVAILABLE, FieldTypes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| """Entry points discovery for ZnTrack nodes. | ||
|
|
||
| This module provides functionality to discover and load all packages | ||
| that have registered entry points under 'zntrack.nodes'. | ||
| """ | ||
|
|
||
| import importlib | ||
| import importlib.metadata | ||
| import logging | ||
| from collections import defaultdict | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def get_registered_nodes(group: str = "zntrack.nodes") -> dict[str, list[str]]: | ||
| """Get all packages that registered into [project.entry-points.'zntrack.nodes'].""" | ||
| registered_nodes = defaultdict(list) | ||
|
|
||
| try: | ||
| # Get all entry points for the 'zntrack.nodes' group | ||
| entry_points = importlib.metadata.entry_points(group=group) | ||
|
|
||
| for entry_point in entry_points: | ||
| try: | ||
| # Load the function registered at this entry point | ||
| nodes_func = entry_point.load() | ||
|
|
||
| # Call the function to get the dictionary of module -> node names | ||
| nodes_dict = nodes_func() | ||
|
|
||
| for module_name, node_names in nodes_dict.items(): | ||
| module_name = module_name.replace("-", "_") # Normalize module names | ||
| registered_nodes[module_name].extend(node_names) | ||
|
|
||
| except Exception as e: | ||
| log.error(f"Failed to load entry point '{entry_point.name}': {e}") | ||
| continue | ||
|
|
||
| except Exception as e: | ||
| log.error(f"Failed to discover entry points: {e}") | ||
|
|
||
| return dict(registered_nodes) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| """ZnTrack Model Context Provider (MCP) integration. | ||
|
|
||
| Example | ||
| ------- | ||
| To connect the ZnTrack MCP server to claude code at the current working directory, run: | ||
|
|
||
| ```bash | ||
| bunx @anthropic-ai/claude-code mcp add zntrack-server -- uv run \ | ||
| --project "$(pwd)" zntrack-mcp | ||
| bunx @anthropic-ai/claude-code | ||
| ``` | ||
| """ | ||
|
|
||
| from zntrack.mcp.server import mcp | ||
|
|
||
| __all__ = ["mcp"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ```python | ||
| import zntrack | ||
| from package import Node1, Node2 | ||
|
|
||
| project = zntrack.Project() | ||
|
|
||
| with project: | ||
| node1 = Node1(param="value1") | ||
| node2 = Node2(input=node1.output) | ||
|
|
||
| if __name__ == "__main__": | ||
| project.build() | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| ```python | ||
| import zntrack | ||
| from package import Node1, Node2 | ||
|
|
||
| project = zntrack.Project() | ||
|
|
||
| with zntrack.group("group1"): | ||
| node1 = Node1(param="value1") | ||
|
|
||
| with zntrack.group("group2"): | ||
| node2 = Node2(input=node1.output) | ||
|
|
||
| with project.group("group1", "nested"): | ||
| node3 = Node1(param="value2") | ||
|
|
||
| if __name__ == "__main__": | ||
| project.build() | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| ```py | ||
| import zntrack | ||
| from pathlib import Path | ||
|
|
||
| class MyNode(zntrack.Node): | ||
| parameter: dict = zntrack.params() | ||
| output: Path = zntrack.outs_path(zntrack.nwd / "file.txt") | ||
|
|
||
| def run(self) -> None: | ||
| self.output.parent.mkdir(parents=True, exist_ok=True) | ||
| self.output.write_text(str(self.parameter)) | ||
| ``` | ||
|
|
||
| Options include | ||
| - `zntrack.deps()` for dependencies to other nodes. | ||
| - `zntrack.deps_path` for dependencies to files. | ||
| - `zntrack.params` for parameters. | ||
| - `zntrack.params_path()` for parameter files (yaml / json) | ||
| - `zntrack.outs_path()` for output files. | ||
| - `zntrack.outs()` for outputs that are not files. | ||
| - `zntrack.metrics()` dict output. | ||
| - `zntrack.metrics_path()` for metrics files. | ||
|
|
||
| Special directory options include | ||
| - `zntrack.nwd` for the node working directory. |
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.
💡 Verification agent
🧩 Analysis chain
Verify UV sources configuration for production readiness.
The UV sources configuration uses local editable paths and git sources, which suggests this is configured for development. Ensure this configuration is appropriate for the intended deployment environment.
🏁 Script executed:
Length of output: 523
Update UV sources for production readiness
The relative paths for
ipsuite,massband, andmlipxdo not exist in the sandbox and will break installs outside your local dev setup, whereas thecp2k-input-toolsgit source is reachable. Please replace those editable local‐path entries with stable package references (for example, a PyPI version or a git URL pinned to a release tag) or move them into a development-only profile.• File: pyproject.toml, section
[tool.uv.sources]Ensure this aligns with your release process so that installing from
pyproject.tomlworks in CI, production, and user setups.🤖 Prompt for AI Agents