-
Notifications
You must be signed in to change notification settings - Fork 7
Update ROI_table_names
argument of copy_ome_zarr
#448
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
Comments
So how would we provide default "lists" of arguments best? Normally, I'd say we provide tuples in such a case, though I'm not sure what the schema / fractal-web implication of introducing tuples would be. |
Using tuples looks like a good idea, but we need the For the record, PEP 484 (which appeared for Python 3.5) states:
|
Let's see if we hit any unexpected edge case, but the JSON-Schema side of this solution is quite transparent (see the manifest diff in 55ae926): "ROI_table_names": {
"title": "Roi Table Names",
+ "default": [
+ "FOV_ROI_table",
+ "well_ROI_table"
+ ],
"type": "array",
"items": { Therefore this could provide a nice little workaround, which is simple to implement in Python and simple to document. Let's continue in fractal-analytics-platform/fractal-task-tools#6. |
This was closed, but it needs to be re-opened.
If we remove one item from the two-items list, we get only one. If we remove both, we go back to the default value (i.e. both items). |
Ok, but that's now a different issue to me. The user can see and change what ROI tables are copied. Due to the issue with [], it can't be validated as a correct input though if an empty list is provided. This doesn't need to be fixed for 0.10.0, let's think about how we want to eventually handle this though. |
I agree: viewing the ROI-table names is better than relying on the side effects of an empty list (which is then transformed to null, removed, and finally set to a default value from within the task). It's clearly an improvement! Still: Fractal as a whole (tasks+server+web) doesn't support passing an empty-list argument, but for this task it could be useful (if I want to play with a minimal OME-Zarr, which has no ROI tables). We can improve the task, and maybe only raise warnings if the required ROI tables do not exist, but the main issue remains.
That would be too late anyway ;) |
Note that |
Ref:
null vs []
(for arrays and objects in task arguments) fractal-web#209Python
In principle we'd like to support multiple use cases:
ROI_table_names = ["something", "else"]
-> only these ROIs are copiedROI_table_names = None
-> some default ROIs are copied (i.e."FOV_ROI_table", "well_ROI_table"]
)ROI_table_names = []
-> no ROIs are copiedSupport for all three cases is already in-place in the Python function, but it's not fractal-web-friendly.
JSON Schema and fractal-web
The relevant bit of the JSON Schema is
This means that the following
args
are identified as valid by a JSON Schema validator:However, we are currently stripping empty objects/arrays from server API calls in fractal-web (ref fractal-analytics-platform/fractal-web#209). This is in principle an arbitrary choice, but we don't want to end up with a a case-by-case heuristics for what should be done - since the current JSON Schema does not provide any guidance here (all three cases above are valid).
Back to Python
The obvious solution would be to set
but having mutable default values is a bad practice which we should avoid.
(For the record: it wouldn't matter in our Fractal-embedded use of tasks, but it would be risky when someone uses tasks as Python functions, therefore we should simply avoid it).
This issue is to find an alternative solution, if any.
The text was updated successfully, but these errors were encountered: