Skip to content

Commit 34cffcd

Browse files
authored
Merge pull request #532 from fractal-analytics-platform/pydantic_v2
Supported pydantic_v2 schemas
2 parents 1b6285d + 9e15b70 commit 34cffcd

File tree

10 files changed

+22
-12
lines changed

10 files changed

+22
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
*Note: Numbers like (\#123) point to closed Pull Requests on the fractal-web repository.*
22

3+
# Unreleased
4+
5+
* Supported `pydantic_v2` schemas (\#532);
6+
37
# 1.3.1
48

59
* Fixed custom key not displayed in JSON Schema form (\#529);

sandbox/src/lib/components/TaskManifestSandbox.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@
7070
throw new Error('Invalid manifest format');
7171
} else if (manifestData.manifest_version !== '2') {
7272
throw new Error('Unsupported manifest version');
73-
} else if (manifestData.args_schema_version !== 'pydantic_v1') {
73+
} else if (
74+
manifestData.args_schema_version !== 'pydantic_v2' &&
75+
manifestData.args_schema_version !== 'pydantic_v1'
76+
) {
7477
throw new Error('Unsupported manifest args schema version');
7578
} else {
7679
return manifestData;

sandbox/src/lib/components/manifest_v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"title": "ManifestV2",
3-
"description": "Packages containing tasks are required to include a special file\n`__FRACTAL_MANIFEST__.json` in order to be discovered and used by Fractal.\n\nThis model class and the model classes it depends on provide the base\nschema to read, write and validate manifests.\n\nAttributes:\n manifest_version:\n A version string that provides indication for compatibility between\n manifests as the schema evolves. This is for instance used by\n Fractal to determine which subclass of the present base class needs\n be used to read and validate the input.\n task_list : list[TaskManifestType]\n The list of tasks, represented as specified by subclasses of the\n _TaskManifestBase (a.k.a. TaskManifestType)\n has_args_schemas:\n `True` if the manifest incldues JSON Schemas for the arguments of\n each task.\n args_schema_version:\n Label of how `args_schema`s were generated (e.g. `pydantic_v1`).",
3+
"description": "Packages containing tasks are required to include a special file\n`__FRACTAL_MANIFEST__.json` in order to be discovered and used by Fractal.\n\nThis model class and the model classes it depends on provide the base\nschema to read, write and validate manifests.\n\nAttributes:\n manifest_version:\n A version string that provides indication for compatibility between\n manifests as the schema evolves. This is for instance used by\n Fractal to determine which subclass of the present base class needs\n be used to read and validate the input.\n task_list : list[TaskManifestType]\n The list of tasks, represented as specified by subclasses of the\n _TaskManifestBase (a.k.a. TaskManifestType)\n has_args_schemas:\n `True` if the manifest incldues JSON Schemas for the arguments of\n each task.\n args_schema_version:\n Label of how `args_schema`s were generated (e.g. `pydantic_v2`).",
44
"type": "object",
55
"properties": {
66
"manifest_version": {

src/lib/components/v1/workflow/ArgumentsSchema.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { deepCopy } from '$lib/common/component_utilities';
99
import { JsonSchemaDataError } from 'fractal-jschema/components/form_manager';
1010
11-
const SUPPORTED_SCHEMA_VERSIONS = ['pydantic_v1'];
11+
const SUPPORTED_SCHEMA_VERSIONS = ['pydantic_v1', 'pydantic_v2'];
1212
1313
/** @type {import('$lib/components/common/StandardErrorAlert.svelte').default|undefined} */
1414
let errorAlert = undefined;

src/lib/components/v2/tasks/AddSingleTask.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
let version = '';
2424
let docs_info = '';
2525
let docs_link = '';
26-
let args_schema_version = 'pydantic_v1';
26+
let args_schema_version = 'pydantic_v2';
2727
/** @type {import('$lib/types-v2').TaskV2Type} */
2828
let taskType = 'non_parallel';
2929
@@ -314,7 +314,7 @@
314314
typesEditor.init({}, {});
315315
docs_info = '';
316316
docs_link = '';
317-
args_schema_version = 'pydantic_v1';
317+
args_schema_version = 'pydantic_v2';
318318
clearArgsSchemaNonParallelFileUpload();
319319
clearArgsSchemaParallelFileUpload();
320320
clearMetaNonParallelFileUpload();

src/lib/components/v2/tasks/CustomEnvTask.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
throw new Error('Invalid manifest format');
5555
} else if (manifestData.manifest_version !== '2') {
5656
throw new Error('Unsupported manifest version');
57-
} else if (manifestData.args_schema_version !== 'pydantic_v1') {
57+
} else if (
58+
manifestData.args_schema_version !== 'pydantic_v2' &&
59+
manifestData.args_schema_version !== 'pydantic_v1'
60+
) {
5861
throw new Error('Unsupported manifest args schema version');
5962
} else {
6063
return manifestData;

src/lib/components/v2/tasks/manifest_v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"title": "ManifestV2",
3-
"description": "Packages containing tasks are required to include a special file\n`__FRACTAL_MANIFEST__.json` in order to be discovered and used by Fractal.\n\nThis model class and the model classes it depends on provide the base\nschema to read, write and validate manifests.\n\nAttributes:\n manifest_version:\n A version string that provides indication for compatibility between\n manifests as the schema evolves. This is for instance used by\n Fractal to determine which subclass of the present base class needs\n be used to read and validate the input.\n task_list : list[TaskManifestType]\n The list of tasks, represented as specified by subclasses of the\n _TaskManifestBase (a.k.a. TaskManifestType)\n has_args_schemas:\n `True` if the manifest incldues JSON Schemas for the arguments of\n each task.\n args_schema_version:\n Label of how `args_schema`s were generated (e.g. `pydantic_v1`).",
3+
"description": "Packages containing tasks are required to include a special file\n`__FRACTAL_MANIFEST__.json` in order to be discovered and used by Fractal.\n\nThis model class and the model classes it depends on provide the base\nschema to read, write and validate manifests.\n\nAttributes:\n manifest_version:\n A version string that provides indication for compatibility between\n manifests as the schema evolves. This is for instance used by\n Fractal to determine which subclass of the present base class needs\n be used to read and validate the input.\n task_list : list[TaskManifestType]\n The list of tasks, represented as specified by subclasses of the\n _TaskManifestBase (a.k.a. TaskManifestType)\n has_args_schemas:\n `True` if the manifest incldues JSON Schemas for the arguments of\n each task.\n args_schema_version:\n Label of how `args_schema`s were generated (e.g. `pydantic_v2`).",
44
"type": "object",
55
"properties": {
66
"manifest_version": {

src/lib/components/v2/workflow/ArgumentsSchema.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { tick } from 'svelte';
1414
import { JsonSchemaDataError } from 'fractal-jschema/components/form_manager';
1515
16-
const SUPPORTED_SCHEMA_VERSIONS = ['pydantic_v1'];
16+
const SUPPORTED_SCHEMA_VERSIONS = ['pydantic_v1', 'pydantic_v2'];
1717
1818
/** @type {import('$lib/components/common/StandardErrorAlert.svelte').default|undefined} */
1919
let errorAlert = undefined;

tests/v2/add_single_task.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test('Add single tasks [v2]', async ({ page }) => {
4848
expect(task.source).toEqual(`admin:${randomTaskName1}-source`);
4949
expect(task.input_types).toContain('input_type');
5050
expect(task.output_types).toContain('output_type');
51-
expect(task.args_schema_version).toEqual('pydantic_v1');
51+
expect(task.args_schema_version).toEqual('pydantic_v2');
5252
expect(task.docs_info).toEqual('Task title');
5353
expect(task.docs_link).toEqual('https://www.example.com');
5454
});
@@ -81,7 +81,7 @@ test('Add single tasks [v2]', async ({ page }) => {
8181
expect(task.source).toEqual(`admin:${randomTaskName2}-source`);
8282
expect(task.input_types).toContain('input_type');
8383
expect(task.output_types).toContain('output_type');
84-
expect(task.args_schema_version).toEqual('pydantic_v1');
84+
expect(task.args_schema_version).toEqual('pydantic_v2');
8585
expect(task.docs_info).toEqual('Task title');
8686
expect(task.docs_link).toEqual('https://www.example.com');
8787
});
@@ -118,7 +118,7 @@ test('Add single tasks [v2]', async ({ page }) => {
118118
expect(task.source).toEqual(`admin:${randomTaskName3}-source`);
119119
expect(task.input_types).toContain('input_type');
120120
expect(task.output_types).toContain('output_type');
121-
expect(task.args_schema_version).toEqual('pydantic_v1');
121+
expect(task.args_schema_version).toEqual('pydantic_v2');
122122
expect(task.docs_info).toEqual('Task title');
123123
expect(task.docs_link).toEqual('https://www.example.com');
124124
});

tests/v2/custom_env_task.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('Custom Python env task [v2]', async ({ page }) => {
1313
const randomName = Math.random().toString(36).substring(7);
1414

1515
const manifestData = {
16-
args_schema_version: 'pydantic_v1',
16+
args_schema_version: 'pydantic_v2',
1717
has_args_schemas: true,
1818
manifest_version: '2',
1919
task_list: [

0 commit comments

Comments
 (0)