Skip to content

Commit

Permalink
fix: make tasks avaialble in get plugin endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
henrychoy committed Nov 1, 2024
1 parent 2da049c commit a6e532e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/dioptra/restapi/v1/plugins/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,6 @@ class PluginSnapshotRefSchema(PluginSnapshotRefBaseSchema): # type: ignore
)


PluginFileRefBaseSchema = generate_base_resource_ref_schema("PluginFile")


class PluginFileRefSchema(PluginFileRefBaseSchema): # type: ignore
"""The reference schema for the data stored in a PluginFile."""

pluginId = fields.Int(
attribute="plugin_id",
data_key="plugin",
metadata=dict(description="ID for the Plugin resource this file belongs to."),
)
filename = fields.String(
attribute="filename",
metadata=dict(description="Filename of the PluginFile resource."),
)


class PluginTaskParameterSchema(Schema):
"""The schema for the data stored in a PluginTaskParameter"""

Expand Down Expand Up @@ -168,6 +151,29 @@ class PluginTaskSchema(Schema):
)


PluginFileRefBaseSchema = generate_base_resource_ref_schema("PluginFile")


class PluginFileRefSchema(PluginFileRefBaseSchema): # type: ignore
"""The reference schema for the data stored in a PluginFile."""

pluginId = fields.Int(
attribute="plugin_id",
data_key="plugin",
metadata=dict(description="ID for the Plugin resource this file belongs to."),
)
filename = fields.String(
attribute="filename",
metadata=dict(description="Filename of the PluginFile resource."),
)
tasks = fields.Nested(
PluginTaskSchema,
attribute="tasks",
metadata=dict(description="Tasks associated with the PluginFile resource."),
many=True,
)


PluginBaseSchema = generate_base_resource_schema("Plugin", snapshot=True)


Expand Down
1 change: 1 addition & 0 deletions src/dioptra/restapi/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def build_plugin_file_ref(plugin_file: models.PluginFile) -> dict[str, Any]:
"url": build_url(
f"{PLUGINS}/{plugin_id}/{PLUGIN_FILES}/{plugin_file.resource_id}"
),
"tasks": [build_plugin_task(task) for task in plugin_file.tasks]
}


Expand Down

0 comments on commit a6e532e

Please sign in to comment.