Apricot-Therapeutics / APx_fractal_task_collection

A collection of custom fractal tasks.
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Switch to Pydantic V2? #5

Closed tcompa closed 2 months ago

tcompa commented 3 months ago

One of the upcoming fractal-tasks-core releases will depend on pydantic>=2. Using this new fractal-tasks-core version for generating the manifest of APx_fractal_task_collection currently fails, probably because some Pydantic V1 parts of APx should be updated to work with Pydantic v2 -- see below.


This is the failing CI workflow: https://github.com/fractal-analytics-platform/fractal-tasks-core/actions/runs/10006172758/job/27658348914?pr=793.

And here is the relevant bit of traceback for python src/apx_fractal_task_collection/dev/update_manifest.py (which points to https://docs.pydantic.dev/2.8/errors/usage_errors/#root-validator-pre-skip):

Traceback (most recent call last):
  File "/home/runner/work/fractal-tasks-core/fractal-tasks-core/src/apx_fractal_task_collection/dev/update_manifest.py", line 7, in <module>
    create_manifest(package=PACKAGE)
  File "/home/runner/work/fractal-tasks-core/fractal-tasks-core/fractal-tasks-core/fractal_tasks_core/dev/create_manifest.py", line 117, in create_manifest
    schema = create_schema_for_single_task(
  File "/home/runner/work/fractal-tasks-core/fractal-tasks-core/fractal-tasks-core/fractal_tasks_core/dev/lib_args_schemas.py", line 279, in create_schema_for_single_task
    task_function = _extract_function(
  File "/home/runner/work/fractal-tasks-core/fractal-tasks-core/fractal-tasks-core/fractal_tasks_core/dev/lib_signature_constraints.py", line 59, in _extract_function
    imported_module = import_module(
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/runner/work/fractal-tasks-core/fractal-tasks-core/src/apx_fractal_task_collection/tasks/measure_features.py", line 21, in <module>
    from apx_fractal_task_collection.utils import (
  File "/home/runner/work/fractal-tasks-core/fractal-tasks-core/src/apx_fractal_task_collection/utils.py", line 287, in <module>
    class TextureFeatures(BaseModel):
  File "/home/runner/work/fractal-tasks-core/fractal-tasks-core/src/apx_fractal_task_collection/utils.py", line 308, in TextureFeatures
    def validate_conditions(cls, values):
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/pydantic/deprecated/class_validators.py", line 234, in root_validator
    return root_validator()(*__args)  # type: ignore
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/pydantic/deprecated/class_validators.py", line 240, in root_validator
    raise PydanticUserError(
pydantic.errors.PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`. Note that `@root_validator` is deprecated and should be replaced with `@model_validator`.
adrtsc commented 3 months ago

Thanks for the heads up @tcompa. I tried to update everything to pydantic v2.0 on https://github.com/Apricot-Therapeutics/APx_fractal_task_collection/tree/pydantic_v2. Works for me locally, let me know if something is still wrong.

tcompa commented 2 months ago

Works for me locally, let me know if something is still wrong.

It does work, thanks!


First, our GitHub Action now runs successfully: https://github.com/fractal-analytics-platform/fractal-tasks-core/actions/runs/10037714190/job/27738094738?pr=793.


Second, I cloned the apx repo to review how the manifest is changing.

git switch pydantic_v2

# Make the JSON diff a bit more readable
echo "*.json diff=json" >> .gitattributes && git config diff.json.textconv "jq --sort-keys '.' \$1"

# Actually run the diff
git diff main  src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json

The diff output is below. Apart from the definitions->$defs change, I don't see any risky change. A second review would be helpful.

diff --git a/src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json b/src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json
index c7fe603..51c7486 100644
--- a/src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json
+++ b/src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json
@@ -1,22 +1,21 @@
 {
-  "args_schema_version": "pydantic_v1",
+  "args_schema_version": "pydantic_v2",
   "has_args_schemas": true,
   "manifest_version": "2",
   "task_list": [
     {
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "ChannelInputModel": {
             "description": "A channel which is specified by either `wavelength_id` or `label`.",
             "properties": {
               "label": {
-                "description": "Name of the channel.",
+                "description": "Name of the channel. Can only be specified if wavelength_id is not set.",
                 "title": "Label",
                 "type": "string"
               },
               "wavelength_id": {
-                "description": "Unique ID for the channel wavelength, e.g. `A01_C01`.",
+                "description": "Unique ID for the channel wavelength, e.g. `A01_C01`. Can only be specified if label is not set.",
                 "title": "Wavelength Id",
                 "type": "string"
               }
@@ -55,6 +54,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "ROI_table_name": {
             "description": "Missing description",
@@ -70,7 +70,7 @@
           "channels_to_exclude": {
             "description": "List of channels to exclude for intensity and texture measurements. Use the channel label to indicate single channels. If None, no channels are excluded.",
             "items": {
-              "$ref": "#/definitions/ChannelInputModel"
+              "$ref": "#/$defs/ChannelInputModel"
             },
             "title": "Channels To Exclude",
             "type": "array"
@@ -78,7 +78,7 @@
           "channels_to_include": {
             "description": "List of channels to include for intensity and texture measurements. Use the channel label to indicate single channels. If None, all channels are included.",
             "items": {
-              "$ref": "#/definitions/ChannelInputModel"
+              "$ref": "#/$defs/ChannelInputModel"
             },
             "title": "Channels To Include",
             "type": "array"
@@ -115,7 +115,7 @@
           "measure_texture": {
             "allOf": [
               {
-                "$ref": "#/definitions/TextureFeatures"
+                "$ref": "#/$defs/TextureFeatures"
               }
             ],
             "default": {
@@ -210,8 +210,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsSegmentSecondary": {
             "description": "Segment Secondary HCS Plate init args.",
             "properties": {
@@ -250,6 +249,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "ROI_table_name": {
             "description": "Name of the table containing the ROIs.",
@@ -273,9 +273,9 @@
             "type": "integer"
           },
           "init_args": {
-            "$ref": "#/definitions/InitArgsSegmentSecondary",
+            "$ref": "#/$defs/InitArgsSegmentSecondary",
             "description": "Intialization arguments provided by `init_segment_secondary_objects`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -330,15 +330,14 @@
     },
     {
       "args_schema_non_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "MultiplexingAcquisition": {
             "description": "Input class for Multiplexing Cellvoyager converter",
             "properties": {
               "allowed_channels": {
                 "description": "A list of `OmeroChannel` objects, where each channel must include the `wavelength_id` attribute and where the `wavelength_id` values must be unique across the list.",
                 "items": {
-                  "$ref": "#/definitions/OmeroChannel"
+                  "$ref": "#/$defs/OmeroChannel"
                 },
                 "title": "Allowed Channels",
                 "type": "array"
@@ -398,7 +397,11 @@
                 "type": "string"
               },
               "window": {
-                "$ref": "#/definitions/Window",
+                "allOf": [
+                  {
+                    "$ref": "#/$defs/Window"
+                  }
+                ],
                 "description": "Optional `Window` object to set default display settings for napari.",
                 "title": "Window"
               }
@@ -441,10 +444,11 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "acquisitions": {
             "additionalProperties": {
-              "$ref": "#/definitions/MultiplexingAcquisition"
+              "$ref": "#/$defs/MultiplexingAcquisition"
             },
             "description": "dictionary of acquisitions. Each key is the acquisition identifier (normally 0, 1, 2, 3 etc.). Each item defines the acquisition by providing the image_dir and the allowed_channels.",
             "title": "Acquisitions",
@@ -505,8 +509,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsIC6000": {
             "description": "Arguments to be passed from IC6000 converter init to compute",
             "properties": {
@@ -542,17 +545,20 @@
               "image_dir",
               "plate_prefix",
               "well_ID",
-              "image_extension"
+              "image_extension",
+              "image_glob_patterns",
+              "acquisition"
             ],
             "title": "InitArgsIC6000",
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsIC6000",
+            "$ref": "#/$defs/InitArgsIC6000",
             "description": "Intialization arguments provided by `init_convert_IC600_to_ome_zarr`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "zarr_url": {
             "description": "Path or url to the individual OME-Zarr image to be processed. (standard argument for Fractal tasks, managed by Fractal server).",
@@ -614,8 +620,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsLabelAssignment": {
             "description": "Arguments to be passed from Label Assignment init to compute",
             "properties": {
@@ -646,6 +651,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "child_table_name": {
             "description": "Name of the feature table associated with the child label image.",
@@ -653,9 +659,9 @@
             "type": "string"
           },
           "init_args": {
-            "$ref": "#/definitions/InitArgsLabelAssignment",
+            "$ref": "#/$defs/InitArgsLabelAssignment",
             "description": "Intialization arguments provided by `init_label_assignment_by_overlap`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -736,8 +742,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsClipLabelImage": {
             "description": "Arguments to be passed from Clip Label Image init to compute",
             "properties": {
@@ -768,11 +773,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsClipLabelImage",
+            "$ref": "#/$defs/InitArgsClipLabelImage",
             "description": "Intialization arguments provided by `init_clip_label_image`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -858,8 +864,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsMaskLabelImage": {
             "description": "Arguments to be passed from Mask Label Image init to compute",
             "properties": {
@@ -890,11 +895,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsMaskLabelImage",
+            "$ref": "#/$defs/InitArgsMaskLabelImage",
             "description": "Intialization arguments provided by `init_clip_label_image`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -974,8 +980,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsFilterLabelBySize": {
             "description": "Arguments to be passed from Filter Label by Size init to compute",
             "properties": {
@@ -996,11 +1001,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsFilterLabelBySize",
+            "$ref": "#/$defs/InitArgsFilterLabelBySize",
             "description": "Intialization arguments provided by `init_filter_label_by_size`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -1090,8 +1096,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsBaSiCPyCalculate": {
             "description": "Arguments to be passed from BaSiCPy Calculate init to compute",
             "properties": {
@@ -1128,6 +1133,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "illumination_profiles_folder": {
             "description": "Path to folder where illumination profiles will be saved.",
@@ -1135,9 +1141,9 @@
             "type": "string"
           },
           "init_args": {
-            "$ref": "#/definitions/InitArgsBaSiCPyCalculate",
+            "$ref": "#/$defs/InitArgsBaSiCPyCalculate",
             "description": "Intialization arguments provided by `init_calculate_basicpy_illumination_models`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "overwrite": {
             "default": false,
@@ -1256,8 +1262,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsAggregateFeatureTables": {
             "description": "Arguments to be passed from BaSiCPy Calculate init to compute",
             "properties": {
@@ -1276,11 +1281,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsAggregateFeatureTables",
+            "$ref": "#/$defs/InitArgsAggregateFeatureTables",
             "description": "Missing description",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "input_table_name": {
             "description": "Name of the feature table.",
@@ -1544,8 +1550,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsCorrectChromaticShift": {
             "description": "Arguments to be passed from Correct Chromatic Shift init to compute",
             "properties": {
@@ -1572,11 +1577,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsCorrectChromaticShift",
+            "$ref": "#/$defs/InitArgsCorrectChromaticShift",
             "description": "Intialization arguments provided by `init_correct_chromatic_shift.py`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "overwrite_input": {
             "default": true,
@@ -1656,8 +1662,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsConvertChannelToLabel": {
             "description": "Arguments to be passed from Convert Channel to Label init to compute",
             "properties": {
@@ -1678,11 +1683,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsConvertChannelToLabel",
+            "$ref": "#/$defs/InitArgsConvertChannelToLabel",
             "description": "Missing description",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "output_label_name": {
             "description": "Missing description",
@@ -1756,8 +1762,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsDetectBlobCentroids": {
             "description": "Arguments to be passed from Convert Channel to Label init to compute",
             "properties": {
@@ -1778,6 +1783,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "ROI_table_name": {
             "description": "Name of the table containing the ROIs.",
@@ -1785,9 +1791,9 @@
             "type": "string"
           },
           "init_args": {
-            "$ref": "#/definitions/InitArgsDetectBlobCentroids",
+            "$ref": "#/$defs/InitArgsDetectBlobCentroids",
             "description": "Intialization arguments provided by `init_detect_blob_centroids`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -1863,24 +1869,23 @@
   ]
 }
 {
-  "args_schema_version": "pydantic_v1",
+  "args_schema_version": "pydantic_v2",
   "has_args_schemas": true,
   "manifest_version": "2",
   "task_list": [
     {
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "ChannelInputModel": {
             "description": "A channel which is specified by either `wavelength_id` or `label`.",
             "properties": {
               "label": {
-                "description": "Name of the channel.",
+                "description": "Name of the channel. Can only be specified if wavelength_id is not set.",
                 "title": "Label",
                 "type": "string"
               },
               "wavelength_id": {
-                "description": "Unique ID for the channel wavelength, e.g. `A01_C01`.",
+                "description": "Unique ID for the channel wavelength, e.g. `A01_C01`. Can only be specified if label is not set.",
                 "title": "Wavelength Id",
                 "type": "string"
               }
@@ -1919,6 +1924,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "ROI_table_name": {
             "description": "Missing description",
@@ -1934,7 +1940,7 @@
           "channels_to_exclude": {
             "description": "List of channels to exclude for intensity and texture measurements. Use the channel label to indicate single channels. If None, no channels are excluded.",
             "items": {
-              "$ref": "#/definitions/ChannelInputModel"
+              "$ref": "#/$defs/ChannelInputModel"
             },
             "title": "Channels To Exclude",
             "type": "array"
@@ -1942,7 +1948,7 @@
           "channels_to_include": {
             "description": "List of channels to include for intensity and texture measurements. Use the channel label to indicate single channels. If None, all channels are included.",
             "items": {
-              "$ref": "#/definitions/ChannelInputModel"
+              "$ref": "#/$defs/ChannelInputModel"
             },
             "title": "Channels To Include",
             "type": "array"
@@ -1979,7 +1985,7 @@
           "measure_texture": {
             "allOf": [
               {
-                "$ref": "#/definitions/TextureFeatures"
+                "$ref": "#/$defs/TextureFeatures"
               }
             ],
             "default": {
@@ -2074,8 +2080,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsSegmentSecondary": {
             "description": "Segment Secondary HCS Plate init args.",
             "properties": {
@@ -2114,6 +2119,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "ROI_table_name": {
             "description": "Name of the table containing the ROIs.",
@@ -2137,9 +2143,9 @@
             "type": "integer"
           },
           "init_args": {
-            "$ref": "#/definitions/InitArgsSegmentSecondary",
+            "$ref": "#/$defs/InitArgsSegmentSecondary",
             "description": "Intialization arguments provided by `init_segment_secondary_objects`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2194,15 +2200,14 @@
     },
     {
       "args_schema_non_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "MultiplexingAcquisition": {
             "description": "Input class for Multiplexing Cellvoyager converter",
             "properties": {
               "allowed_channels": {
                 "description": "A list of `OmeroChannel` objects, where each channel must include the `wavelength_id` attribute and where the `wavelength_id` values must be unique across the list.",
                 "items": {
-                  "$ref": "#/definitions/OmeroChannel"
+                  "$ref": "#/$defs/OmeroChannel"
                 },
                 "title": "Allowed Channels",
                 "type": "array"
@@ -2262,7 +2267,11 @@
                 "type": "string"
               },
               "window": {
-                "$ref": "#/definitions/Window",
+                "allOf": [
+                  {
+                    "$ref": "#/$defs/Window"
+                  }
+                ],
                 "description": "Optional `Window` object to set default display settings for napari.",
                 "title": "Window"
               }
@@ -2305,10 +2314,11 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "acquisitions": {
             "additionalProperties": {
-              "$ref": "#/definitions/MultiplexingAcquisition"
+              "$ref": "#/$defs/MultiplexingAcquisition"
             },
             "description": "dictionary of acquisitions. Each key is the acquisition identifier (normally 0, 1, 2, 3 etc.). Each item defines the acquisition by providing the image_dir and the allowed_channels.",
             "title": "Acquisitions",
@@ -2369,8 +2379,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsIC6000": {
             "description": "Arguments to be passed from IC6000 converter init to compute",
             "properties": {
@@ -2406,17 +2415,20 @@
               "image_dir",
               "plate_prefix",
               "well_ID",
-              "image_extension"
+              "image_extension",
+              "image_glob_patterns",
+              "acquisition"
             ],
             "title": "InitArgsIC6000",
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsIC6000",
+            "$ref": "#/$defs/InitArgsIC6000",
             "description": "Intialization arguments provided by `init_convert_IC600_to_ome_zarr`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "zarr_url": {
             "description": "Path or url to the individual OME-Zarr image to be processed. (standard argument for Fractal tasks, managed by Fractal server).",
@@ -2478,8 +2490,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsLabelAssignment": {
             "description": "Arguments to be passed from Label Assignment init to compute",
             "properties": {
@@ -2510,6 +2521,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "child_table_name": {
             "description": "Name of the feature table associated with the child label image.",
@@ -2517,9 +2529,9 @@
             "type": "string"
           },
           "init_args": {
-            "$ref": "#/definitions/InitArgsLabelAssignment",
+            "$ref": "#/$defs/InitArgsLabelAssignment",
             "description": "Intialization arguments provided by `init_label_assignment_by_overlap`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2600,8 +2612,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsClipLabelImage": {
             "description": "Arguments to be passed from Clip Label Image init to compute",
             "properties": {
@@ -2632,11 +2643,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsClipLabelImage",
+            "$ref": "#/$defs/InitArgsClipLabelImage",
             "description": "Intialization arguments provided by `init_clip_label_image`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2722,8 +2734,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsMaskLabelImage": {
             "description": "Arguments to be passed from Mask Label Image init to compute",
             "properties": {
@@ -2754,11 +2765,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsMaskLabelImage",
+            "$ref": "#/$defs/InitArgsMaskLabelImage",
             "description": "Intialization arguments provided by `init_clip_label_image`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2838,8 +2850,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsFilterLabelBySize": {
             "description": "Arguments to be passed from Filter Label by Size init to compute",
             "properties": {
@@ -2860,11 +2871,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsFilterLabelBySize",
+            "$ref": "#/$defs/InitArgsFilterLabelBySize",
             "description": "Intialization arguments provided by `init_filter_label_by_size`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2954,8 +2966,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsBaSiCPyCalculate": {
             "description": "Arguments to be passed from BaSiCPy Calculate init to compute",
             "properties": {
@@ -2992,6 +3003,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "illumination_profiles_folder": {
             "description": "Path to folder where illumination profiles will be saved.",
@@ -2999,9 +3011,9 @@
             "type": "string"
           },
           "init_args": {
-            "$ref": "#/definitions/InitArgsBaSiCPyCalculate",
+            "$ref": "#/$defs/InitArgsBaSiCPyCalculate",
             "description": "Intialization arguments provided by `init_calculate_basicpy_illumination_models`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "overwrite": {
             "default": false,
@@ -3120,8 +3132,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsAggregateFeatureTables": {
             "description": "Arguments to be passed from BaSiCPy Calculate init to compute",
             "properties": {
@@ -3140,11 +3151,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsAggregateFeatureTables",
+            "$ref": "#/$defs/InitArgsAggregateFeatureTables",
             "description": "Missing description",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "input_table_name": {
             "description": "Name of the feature table.",
@@ -3408,8 +3420,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsCorrectChromaticShift": {
             "description": "Arguments to be passed from Correct Chromatic Shift init to compute",
             "properties": {
@@ -3436,11 +3447,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsCorrectChromaticShift",
+            "$ref": "#/$defs/InitArgsCorrectChromaticShift",
             "description": "Intialization arguments provided by `init_correct_chromatic_shift.py`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "overwrite_input": {
             "default": true,
@@ -3520,8 +3532,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsConvertChannelToLabel": {
             "description": "Arguments to be passed from Convert Channel to Label init to compute",
             "properties": {
@@ -3542,11 +3553,12 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "init_args": {
-            "$ref": "#/definitions/InitArgsConvertChannelToLabel",
+            "$ref": "#/$defs/InitArgsConvertChannelToLabel",
             "description": "Missing description",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "output_label_name": {
             "description": "Missing description",
@@ -3620,8 +3632,7 @@
         "type": "object"
       },
       "args_schema_parallel": {
-        "additionalProperties": false,
-        "definitions": {
+        "$defs": {
           "InitArgsDetectBlobCentroids": {
             "description": "Arguments to be passed from Convert Channel to Label init to compute",
             "properties": {
@@ -3642,6 +3653,7 @@
             "type": "object"
           }
         },
+        "additionalProperties": false,
         "properties": {
           "ROI_table_name": {
             "description": "Name of the table containing the ROIs.",
@@ -3649,9 +3661,9 @@
             "type": "string"
           },
           "init_args": {
-            "$ref": "#/definitions/InitArgsDetectBlobCentroids",
+            "$ref": "#/$defs/InitArgsDetectBlobCentroids",
             "description": "Intialization arguments provided by `init_detect_blob_centroids`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
tcompa commented 2 months ago

As a second check, I replaced $defs with definitions by hand, to see what diff would remain

sed -i -e 's/$defs/definitions/g' src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json
git diff src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json

And here is the (more readable) output

diff --git a/src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json b/src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json
index c7fe603..54ca130 100644
--- a/src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json
+++ b/src/apx_fractal_task_collection/__FRACTAL_MANIFEST__.json
@@ -1,5 +1,5 @@
 {
-  "args_schema_version": "pydantic_v1",
+  "args_schema_version": "pydantic_v2",
   "has_args_schemas": true,
   "manifest_version": "2",
   "task_list": [
@@ -11,12 +11,12 @@
             "description": "A channel which is specified by either `wavelength_id` or `label`.",
             "properties": {
               "label": {
-                "description": "Name of the channel.",
+                "description": "Name of the channel. Can only be specified if wavelength_id is not set.",
                 "title": "Label",
                 "type": "string"
               },
               "wavelength_id": {
-                "description": "Unique ID for the channel wavelength, e.g. `A01_C01`.",
+                "description": "Unique ID for the channel wavelength, e.g. `A01_C01`. Can only be specified if label is not set.",
                 "title": "Wavelength Id",
                 "type": "string"
               }
@@ -275,7 +275,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsSegmentSecondary",
             "description": "Intialization arguments provided by `init_segment_secondary_objects`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -398,7 +398,11 @@
                 "type": "string"
               },
               "window": {
-                "$ref": "#/definitions/Window",
+                "allOf": [
+                  {
+                    "$ref": "#/definitions/Window"
+                  }
+                ],
                 "description": "Optional `Window` object to set default display settings for napari.",
                 "title": "Window"
               }
@@ -542,7 +546,9 @@
               "image_dir",
               "plate_prefix",
               "well_ID",
-              "image_extension"
+              "image_extension",
+              "image_glob_patterns",
+              "acquisition"
             ],
             "title": "InitArgsIC6000",
             "type": "object"
@@ -552,7 +558,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsIC6000",
             "description": "Intialization arguments provided by `init_convert_IC600_to_ome_zarr`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "zarr_url": {
             "description": "Path or url to the individual OME-Zarr image to be processed. (standard argument for Fractal tasks, managed by Fractal server).",
@@ -655,7 +661,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsLabelAssignment",
             "description": "Intialization arguments provided by `init_label_assignment_by_overlap`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -772,7 +778,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsClipLabelImage",
             "description": "Intialization arguments provided by `init_clip_label_image`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -894,7 +900,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsMaskLabelImage",
             "description": "Intialization arguments provided by `init_clip_label_image`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -1000,7 +1006,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsFilterLabelBySize",
             "description": "Intialization arguments provided by `init_filter_label_by_size`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -1137,7 +1143,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsBaSiCPyCalculate",
             "description": "Intialization arguments provided by `init_calculate_basicpy_illumination_models`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "overwrite": {
             "default": false,
@@ -1280,7 +1286,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsAggregateFeatureTables",
             "description": "Missing description",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "input_table_name": {
             "description": "Name of the feature table.",
@@ -1576,7 +1582,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsCorrectChromaticShift",
             "description": "Intialization arguments provided by `init_correct_chromatic_shift.py`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "overwrite_input": {
             "default": true,
@@ -1682,7 +1688,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsConvertChannelToLabel",
             "description": "Missing description",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "output_label_name": {
             "description": "Missing description",
@@ -1787,7 +1793,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsDetectBlobCentroids",
             "description": "Intialization arguments provided by `init_detect_blob_centroids`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -1863,7 +1869,7 @@
   ]
 }
 {
-  "args_schema_version": "pydantic_v1",
+  "args_schema_version": "pydantic_v2",
   "has_args_schemas": true,
   "manifest_version": "2",
   "task_list": [
@@ -1875,12 +1881,12 @@
             "description": "A channel which is specified by either `wavelength_id` or `label`.",
             "properties": {
               "label": {
-                "description": "Name of the channel.",
+                "description": "Name of the channel. Can only be specified if wavelength_id is not set.",
                 "title": "Label",
                 "type": "string"
               },
               "wavelength_id": {
-                "description": "Unique ID for the channel wavelength, e.g. `A01_C01`.",
+                "description": "Unique ID for the channel wavelength, e.g. `A01_C01`. Can only be specified if label is not set.",
                 "title": "Wavelength Id",
                 "type": "string"
               }
@@ -2139,7 +2145,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsSegmentSecondary",
             "description": "Intialization arguments provided by `init_segment_secondary_objects`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2262,7 +2268,11 @@
                 "type": "string"
               },
               "window": {
-                "$ref": "#/definitions/Window",
+                "allOf": [
+                  {
+                    "$ref": "#/definitions/Window"
+                  }
+                ],
                 "description": "Optional `Window` object to set default display settings for napari.",
                 "title": "Window"
               }
@@ -2406,7 +2416,9 @@
               "image_dir",
               "plate_prefix",
               "well_ID",
-              "image_extension"
+              "image_extension",
+              "image_glob_patterns",
+              "acquisition"
             ],
             "title": "InitArgsIC6000",
             "type": "object"
@@ -2416,7 +2428,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsIC6000",
             "description": "Intialization arguments provided by `init_convert_IC600_to_ome_zarr`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "zarr_url": {
             "description": "Path or url to the individual OME-Zarr image to be processed. (standard argument for Fractal tasks, managed by Fractal server).",
@@ -2519,7 +2531,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsLabelAssignment",
             "description": "Intialization arguments provided by `init_label_assignment_by_overlap`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2636,7 +2648,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsClipLabelImage",
             "description": "Intialization arguments provided by `init_clip_label_image`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2758,7 +2770,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsMaskLabelImage",
             "description": "Intialization arguments provided by `init_clip_label_image`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -2864,7 +2876,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsFilterLabelBySize",
             "description": "Intialization arguments provided by `init_filter_label_by_size`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
@@ -3001,7 +3013,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsBaSiCPyCalculate",
             "description": "Intialization arguments provided by `init_calculate_basicpy_illumination_models`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "overwrite": {
             "default": false,
@@ -3144,7 +3156,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsAggregateFeatureTables",
             "description": "Missing description",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "input_table_name": {
             "description": "Name of the feature table.",
@@ -3440,7 +3452,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsCorrectChromaticShift",
             "description": "Intialization arguments provided by `init_correct_chromatic_shift.py`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "overwrite_input": {
             "default": true,
@@ -3546,7 +3558,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsConvertChannelToLabel",
             "description": "Missing description",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "output_label_name": {
             "description": "Missing description",
@@ -3651,7 +3663,7 @@
           "init_args": {
             "$ref": "#/definitions/InitArgsDetectBlobCentroids",
             "description": "Intialization arguments provided by `init_detect_blob_centroids`.",
-            "title": "Init_Args"
+            "title": "Init Args"
           },
           "level": {
             "default": 0,
tcompa commented 2 months ago

TL;DR Within the new branch, APX seems to be pydantic-v2/fractal-tasks-core compatible. I'd suggest that you coordinate the merge&release of this update with the corresponding merge&release on fractal-tasks-core (ref https://github.com/fractal-analytics-platform/fractal-tasks-core/pull/793).

adrtsc commented 2 months ago

Thanks for running the additional checks. Will keep an eye on the PR!

tcompa commented 2 months ago

You may want to update your dependency to fractal-tasks-core 1.2.0, which is now fully using pydantic v2.

(and feel free to report any unexpected behavior..)

adrtsc commented 2 months ago

Thanks for the update, apx_fractal_tasks_collection main now has all the pydantic v2 changes.