Skip to content
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

conform to new callback format #274

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/source/ImageSet.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
type: object
required:
- title
- imageName
- assets
- imageMetadata
properties:
title:
description: Readable name or identifier of the asset
imageName:
description: Readable name or identifier of this ImageSet element.
assets:
description: List of generated image assets
type: array
Expand Down
6 changes: 3 additions & 3 deletions docs/source/PipelineCallback.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ properties:
required:
- primaryFilePath
- thumbnailIndex
- sample
- title
- fileMetadata
- imageSet

Expand All @@ -29,8 +29,8 @@ properties:
thumbnailIndex:
description: The index of the image in imageSet which consists of the "label image" thumbnail
type: integer
sample:
description: name of sample, usually file name minus path and extension.
title:
description: File specific, name of file minus path and extension. (Appears redundant.)
type: string
fileMetadata:
description: >
Expand Down
6 changes: 3 additions & 3 deletions docs/source/demo_callback.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
{
"primaryFilePath": "LNII/sbest/sbest-2023-0526-Rename/Spatial_example-2023-0526-Rename1/LNII/F13-TS005.czi",
"thumbnailIndex": 0,
"sample": "Name of sample, usually file name minus path and extension",
"title": "Name of the file, file name minus path and extension",
"fileMetadata": {
"TBD": "TBD"
},
"imageSet": [
{
"title": "Scene #1",
"imageName": "Scene #1",
"imageMetadata": {
"TBD": "TBD"
},
Expand All @@ -33,7 +33,7 @@
]
},
{
"title": "image label",
"imageName": "image label",
"imageMetadata": {
"TBD": "TBD"
},
Expand Down
25 changes: 22 additions & 3 deletions em_workflows/file_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def gen_asset(self, asset_type: str, asset_fp) -> Dict:
:param asset_type: a string that details the type of output file
:param asset_fp: the originating FilePath to "hang" the asset on
:return: the resulting "asset" in the form of a dict
TODO: consider changings asset_type to newly created AssetType enum
"""
assets_fp_no_root = asset_fp.relative_to(self.asset_root)
asset = {"type": asset_type, "path": assets_fp_no_root.as_posix()}
Expand All @@ -184,16 +185,34 @@ def gen_prim_fp_elt(self) -> Dict:
[
{
"primaryFilePath": "Lab/PI/Myproject/MySession/Sample1/file_a.mrc",
"title": "file_a",
"assets": []
"thumbnailIndex": 0,
"fileMetadata": {},
"imageSet": []
}
]

"""
# TODO - update this for czi input, parse out title from OMEXML
title = self.fp_in.stem
primaryFilePath = self.fp_in.relative_to(self.proj_root)
# setting to zero here, most input files will only have a single image elt.
# will update val if czi
thumbnailIndex = 0
fileMetadata = {}
imageMetadata = {}
assets = []
imageSetElement = {
"imageName": title,
"imageMetadata": imageMetadata,
"assets": assets,
}
imageSet = [imageSetElement]
return dict(
primaryFilePath=primaryFilePath.as_posix(), title=title, assets=list()
primaryFilePath=primaryFilePath.as_posix(),
thumbnailIndex=thumbnailIndex,
title=title,
fileMetadata=fileMetadata,
imageSet=imageSet,
)

def copy_workdir_to_assets(self) -> Path:
Expand Down
6 changes: 4 additions & 2 deletions em_workflows/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ def add_asset(prim_fp: dict, asset: dict) -> dict:
funtional style avoids this. This is why the callback data structure is not built inside
the FilePath object at runtime.
"""
# TODO - at the moment we're assuming there's only a single image per file.
# when czi is implmented, we should pass which imageset to use.
if type(asset) is list:
prim_fp["assets"].extend(asset)
prim_fp["imageSet"][0]["assets"].extend(asset)
else:
prim_fp["assets"].append(asset)
prim_fp["imageSet"][0]["assets"].append(asset)
log(f"Added fp elt {asset} to {prim_fp}.")
return prim_fp

Expand Down
Loading