Skip to content

Commit

Permalink
Update manifest dev tool & manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
jluethi committed Sep 19, 2023
1 parent a5d9a27 commit b220c36
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
10 changes: 7 additions & 3 deletions src/fractal_faim_hcs/__FRACTAL_MANIFEST__.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@
"mem": 1000
},
"name": "Create OME-Zarr MD",
"output_type": "zarr"
"output_type": "zarr",
"docs_info": "Create OME-Zarr plate from MD Image Xpress files.",
"docs_link": "https://github.com/jluethi/fractal-faim-hcs"
},
{
"args_schema": {
Expand Down Expand Up @@ -129,7 +131,7 @@
},
"memory_efficient": {
"title": "Memory Efficient",
"default": true,
"default": false,
"type": "boolean",
"description": "Load images via dask (more memory efficient for 3D)"
}
Expand All @@ -151,7 +153,9 @@
"parallelization_level": "image"
},
"name": "Convert MD to OME-Zarr",
"output_type": "zarr"
"output_type": "zarr",
"docs_info": "Converts the image data from the MD image Xpress into OME-Zarr.",
"docs_link": "https://github.com/jluethi/fractal-faim-hcs"
}
]
}
38 changes: 24 additions & 14 deletions src/fractal_faim_hcs/dev/new_args_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,51 @@
"""

import json
import logging
from importlib import import_module
from pathlib import Path

import fractal_faim_hcs
from fractal_tasks_core.dev.lib_args_schemas import (
create_schema_for_single_task,
)
from fractal_tasks_core.dev.lib_task_docs import create_docs_info

PACKAGE = "fractal_faim_hcs"


if __name__ == "__main__":
# Read manifest
manifest_path = Path(fractal_faim_hcs.__file__).parent / "__FRACTAL_MANIFEST__.json"
imported_package = import_module(PACKAGE)
manifest_path = Path(imported_package.__file__).parent / "__FRACTAL_MANIFEST__.json"
with manifest_path.open("r") as f:
manifest = json.load(f)

# Set or check global properties of manifest
# Set global properties of manifest
manifest["has_args_schemas"] = True
manifest["args_schema_version"] = "pydantic_v1"

# Loop over tasks and set or check args schemas
# Loop over tasks
task_list = manifest["task_list"]
for ind, task in enumerate(task_list):
executable = task["executable"]
print(f"[{executable}] Start")
try:
schema = create_schema_for_single_task(
executable, package="fractal_faim_hcs"
)
except AttributeError as e:
print(f"[{executable}] Skip, due to AttributeError")
print(e)
continue
logging.info(f"[{executable}] START")

# Create new JSON Schema for task arguments
schema = create_schema_for_single_task(executable, package=PACKAGE)
manifest["task_list"][ind]["args_schema"] = schema
print("Schema added to manifest")

# Update docs_info, based on task-function description
docs_info = create_docs_info(executable, package=PACKAGE)
docs_link = "https://github.com/jluethi/fractal-faim-hcs"
if docs_info:
manifest["task_list"][ind]["docs_info"] = docs_info
if docs_link:
manifest["task_list"][ind]["docs_link"] = docs_link

logging.info(f"[{executable}] END (new schema/description/link)")
print()

with manifest_path.open("w") as f:
json.dump(manifest, f, indent=2)
f.write("\n")
logging.info(f"Up-to-date manifest stored in {manifest_path.as_posix()}")

0 comments on commit b220c36

Please sign in to comment.