Skip to content

Commit

Permalink
feat(starrynight): add mechanism for automatic update of bilayers schema
Browse files Browse the repository at this point in the history
  • Loading branch information
leoank committed Jan 6, 2025
1 parent 2699b0b commit c00dc24
Show file tree
Hide file tree
Showing 6 changed files with 3,706 additions and 65 deletions.
2 changes: 1 addition & 1 deletion conductor/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies = [
"pydantic~=2.8",
"pydantic-settings~=2.4",
"joblib~=1.3",
"cloudpahtlib[all]>0.18,<1.0",
"cloudpathlib[all]>=0.18,<1.0",
"starrynight",
]

Expand Down
11 changes: 6 additions & 5 deletions starrynight/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ dependencies = [
"numpy<=1.26.4",
"cloudpathlib[all]>=0.18,<1.0",
"joblib<=1.4",
"linkml>=1.8"
]

[project.optional-dependencies]
cellprofiler = [
"cellprofiler-core",
"cellprofiler-library",
"Cellprofiler",
]
# cellprofiler = [
# "cellprofiler-core",
# "cellprofiler-library",
# "Cellprofiler",
# ]
dev = ["pytest", "ruff", "build", "twine"]

[tools.uv.sources]
Expand Down
26 changes: 26 additions & 0 deletions starrynight/src/starrynight/modules/registry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""Modules registry."""

from pathlib import Path

import requests
from linkml.generators import PydanticGenerator
from pipecraft.node import UnitOfWork
from pipecraft.pipeline import Pipeline
from pydantic import BaseModel
Expand Down Expand Up @@ -29,3 +33,25 @@ class Config:


MODULE_REGISTRY: dict[str, StarrynightModule] = {}

VALIDATE_SCHEMA_URL = "https://raw.githubusercontent.com/bilayer-containers/bilayers/master/tests/test_config/validate_schema.yaml"


def update_module_schema() -> None:
"""Download and update the module schema from bilayers."""
schema_yaml = Path(__file__).parent.joinpath("validate_schema.yaml")
schema_path = Path(__file__).parent.joinpath("schema.py")
resp = requests.get(VALIDATE_SCHEMA_URL)
if resp.status_code == 200:
schema_yaml.open("wb").write(resp.content)
else:
raise Exception(
"Unable to Download and update the module schema from bilayers."
)

# Write generated pydantic schema
schema_path.open("w").write(PydanticGenerator(schema_yaml).serialize())


if __name__ == "__main__":
update_module_schema()
Loading

0 comments on commit c00dc24

Please sign in to comment.