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

Migrate Visualizations API to FastAPI #18721

Merged
merged 20 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
441 changes: 441 additions & 0 deletions client/src/api/schema/schema.ts

Large diffs are not rendered by default.

263 changes: 263 additions & 0 deletions lib/galaxy/schema/visualization.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from datetime import datetime
from typing import (
Dict,
List,
Optional,
Union,
)

from pydantic import (
Expand Down Expand Up @@ -100,3 +102,264 @@ class VisualizationSummaryList(RootModel):
default=[],
title="List with detailed information of Visualizations.",
)


class VisualizationRevisionResponse(Model):
model_class: str = Field(
arash77 marked this conversation as resolved.
Show resolved Hide resolved
"VisualizationRevision",
title="Model Class",
description="The model class name for this object.",
)
id: EncodedDatabaseIdField = Field(
...,
title="ID",
description="Encoded ID of the Visualization Revision.",
)
visualization_id: EncodedDatabaseIdField = Field(
...,
title="Visualization ID",
description="Encoded ID of the Visualization.",
)
title: str = Field(
...,
title="Title",
description="The name of the visualization revision.",
)
dbkey: Optional[str] = Field(
None,
title="DbKey",
description="The database key of the visualization.",
)
config: Dict = Field(
...,
title="Config",
description="The config of the visualization revision.",
)


class VisualizationPluginResponse(Model):
name: str = Field(
...,
title="Name",
description="The name of the plugin.",
)
html: str = Field(
...,
title="HTML",
description="The HTML of the plugin.",
)
description: str = Field(
...,
title="Description",
description="The description of the plugin.",
)
logo: Optional[str] = Field(
None,
title="Logo",
description="The logo of the plugin.",
)
title: Optional[str] = Field(
None,
title="Title",
description="The title of the plugin.",
)
target: str = Field(
...,
title="Target",
description="The target of the plugin.",
)
embeddable: bool = Field(
...,
title="Embeddable",
description="Whether the plugin is embeddable.",
)
entry_point: Dict = Field(
...,
title="Entry Point",
description="The entry point of the plugin.",
)
settings: List[Dict] = Field(
...,
title="Settings",
description="The settings of the plugin.",
)
groups: Optional[List[Dict]] = Field(
None,
title="Groups",
description="The groups of the plugin.",
)
specs: Optional[Dict] = Field(
None,
title="Specs",
description="The specs of the plugin.",
)
href: str = Field(
...,
title="Href",
description="The href of the plugin.",
)


class VisualizationShowResponse(Model):
model_class: str = Field(
"Visualization",
title="Model Class",
description="The model class name for this object.",
)
id: EncodedDatabaseIdField = Field(
...,
title="ID",
description="Encoded ID of the Visualization.",
)
title: str = Field(
...,
title="Title",
description="The name of the visualization.",
)
type: str = Field(
...,
title="Type",
description="The type of the visualization.",
)
user_id: EncodedDatabaseIdField = Field(
...,
title="User ID",
description="The ID of the user owning this Visualization.",
)
dbkey: Optional[str] = Field(
None,
title="DbKey",
description="The database key of the visualization.",
)
slug: Optional[str] = Field(
None,
title="Slug",
description="The slug of the visualization.",
)
latest_revision: VisualizationRevisionResponse = Field(
...,
title="Latest Revision",
description="The latest revision of this Visualization.",
)
revisions: List[EncodedDatabaseIdField] = Field(
...,
title="Revisions",
description="A list of encoded IDs of the revisions of this Visualization.",
)
url: str = Field(
...,
title="URL",
description="The URL of the visualization.",
)
username: str = Field(
...,
title="Username",
description="The name of the user owning this Visualization.",
)
email_hash: str = Field(
...,
title="Email Hash",
description="The hash of the email of the user owning this Visualization.",
)
tags: Optional[TagCollection] = Field(
None,
title="Tags",
description="A list of tags to add to this item.",
)
annotation: Optional[str] = Field(
None,
title="Annotation",
description="The annotation of this Visualization.",
)
plugin: Optional[VisualizationPluginResponse] = Field(
None,
title="Plugin",
description="The plugin of this Visualization.",
)


class VisualizationCreateResponse(Model):
id: EncodedDatabaseIdField = Field(
...,
title="ID",
description="Encoded ID of the Visualization.",
)


class VisualizationUpdateResponse(Model):
id: EncodedDatabaseIdField = Field(
...,
title="ID",
description="Encoded ID of the Visualization.",
)
revision: EncodedDatabaseIdField = Field(
...,
title="Revision",
description="Encoded ID of the Visualization Revision.",
)


class VisualizationCreatePayload(Model):
import_id: Optional[DecodedDatabaseIdField] = Field(
None,
title="Import ID",
description="The ID of the imported visualization.",
)
type: Optional[str] = Field(
None,
title="Type",
description="The type of the visualization.",
)
title: Optional[str] = Field(
"Untitled Visualization",
title="Title",
description="The name of the visualization.",
)
dbkey: Optional[str] = Field(
None,
title="DbKey",
description="The database key of the visualization.",
)
slug: Optional[str] = Field(
None,
title="Slug",
description="The slug of the visualization.",
)
annotation: Optional[str] = Field(
None,
title="Annotation",
description="The annotation of the visualization.",
)
config: Optional[dict] = Field(
{},
title="Config",
description="The config of the visualization.",
)
save: Optional[bool] = Field(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a visualization that is not saved ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added this because it existed in the old API!
But yes that is useless to have such a variable.

Copy link
Member

@mvdbeek mvdbeek Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know ? Maybe that's used to preview a visualization ? But if so it would be broken since the None as the id won't validate against the response model.

Copy link
Collaborator Author

@arash77 arash77 Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True,
title="Save",
description="Whether to save the visualization.",
)


class VisualizationUpdatePayload(Model):
title: Optional[str] = Field(
None,
title="Title",
description="The name of the visualization.",
)
dbkey: Optional[str] = Field(
None,
title="DbKey",
description="The database key of the visualization.",
)
deleted: Optional[bool] = Field(
False,
title="Deleted",
description="Whether this Visualization has been deleted.",
)
config: Optional[Union[dict, bytes]] = Field(
{},
title="Config",
description="The config of the visualization.",
)
Loading
Loading