Skip to content

Commit 56b74fe

Browse files
committed
Simplify TagCollection into a Field
It's never used as a model. Prevents ugly component names in client schema due to model recursion in the new `partial_model()` implementation.
1 parent 7608bf6 commit 56b74fe

File tree

3 files changed

+110
-50
lines changed

3 files changed

+110
-50
lines changed

client/src/api/schema/schema.ts

Lines changed: 101 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6655,7 +6655,11 @@ export interface components {
66556655
state_ids: {
66566656
[key: string]: string[];
66576657
};
6658-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
6658+
/**
6659+
* Tags
6660+
* @description The collection of tags associated with an item.
6661+
*/
6662+
tags: string[];
66596663
/**
66606664
* Update Time
66616665
* Format: date-time
@@ -6742,7 +6746,11 @@ export interface components {
67426746
* @description Whether this item has been permanently removed.
67436747
*/
67446748
purged: boolean;
6745-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
6749+
/**
6750+
* Tags
6751+
* @description The collection of tags associated with an item.
6752+
*/
6753+
tags: string[];
67466754
/**
67476755
* Update Time
67486756
* Format: date-time
@@ -8683,7 +8691,11 @@ export interface components {
86838691
state_ids?: {
86848692
[key: string]: string[];
86858693
} | null;
8686-
tags?: components["schemas"]["galaxy__util__config_templates__TagCollection"] | null;
8694+
/**
8695+
* Tags
8696+
* @description The collection of tags associated with an item.
8697+
*/
8698+
tags?: string[] | null;
86878699
/**
86888700
* Update Time
86898701
* @description The last time and date this item was updated.
@@ -8916,7 +8928,11 @@ export interface components {
89168928
state_ids?: {
89178929
[key: string]: string[];
89188930
} | null;
8919-
tags?: components["schemas"]["galaxy__util__config_templates__TagCollection"] | null;
8931+
/**
8932+
* Tags
8933+
* @description The collection of tags associated with an item.
8934+
*/
8935+
tags?: string[] | null;
89208936
/**
89218937
* Update Time
89228938
* @description The last time and date this item was updated.
@@ -9559,7 +9575,11 @@ export interface components {
95599575
* @constant
95609576
*/
95619577
model_class: "HistoryDatasetCollectionAssociation";
9562-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
9578+
/**
9579+
* Tags
9580+
* @description The collection of tags associated with an item.
9581+
*/
9582+
tags: string[];
95639583
};
95649584
/**
95659585
* DatasetCollectionContentElements
@@ -11255,7 +11275,11 @@ export interface components {
1125511275
* @description The current state of this dataset.
1125611276
*/
1125711277
state: components["schemas"]["DatasetState"];
11258-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
11278+
/**
11279+
* Tags
11280+
* @description The collection of tags associated with an item.
11281+
*/
11282+
tags: string[];
1125911283
/**
1126011284
* @description discriminator enum property added by openapi-typescript
1126111285
* @enum {string}
@@ -12255,7 +12279,11 @@ export interface components {
1225512279
* @description The current state of this dataset.
1225612280
*/
1225712281
state?: components["schemas"]["DatasetState"] | null;
12258-
tags?: components["schemas"]["galaxy__util__config_templates__TagCollection"] | null;
12282+
/**
12283+
* Tags
12284+
* @description The collection of tags associated with an item.
12285+
*/
12286+
tags?: string[] | null;
1225912287
/**
1226012288
* Type
1226112289
* @description This is always `file` for datasets.
@@ -12520,7 +12548,11 @@ export interface components {
1252012548
* @description The current state of this dataset.
1252112549
*/
1252212550
state: components["schemas"]["DatasetState"];
12523-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
12551+
/**
12552+
* Tags
12553+
* @description The collection of tags associated with an item.
12554+
*/
12555+
tags: string[];
1252412556
/**
1252512557
* Type
1252612558
* @description This is always `file` for datasets.
@@ -12620,7 +12652,11 @@ export interface components {
1262012652
* @description The current state of this dataset.
1262112653
*/
1262212654
state: components["schemas"]["DatasetState"];
12623-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
12655+
/**
12656+
* Tags
12657+
* @description The collection of tags associated with an item.
12658+
*/
12659+
tags: string[];
1262412660
/**
1262512661
* Type
1262612662
* @description The type of this item.
@@ -12767,7 +12803,11 @@ export interface components {
1276712803
* @description The current state of this dataset.
1276812804
*/
1276912805
state: components["schemas"]["DatasetState"];
12770-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
12806+
/**
12807+
* Tags
12808+
* @description The collection of tags associated with an item.
12809+
*/
12810+
tags: string[];
1277112811
/**
1277212812
* Type
1277312813
* @description The type of this item.
@@ -12927,7 +12967,11 @@ export interface components {
1292712967
* @description A list of objects containing the object store ID and the oldest creation time of the datasets stored in that object store for this collection.This is used to determine the age of the datasets in the collection when the object store is short-lived.
1292812968
*/
1292912969
store_times_summary?: components["schemas"]["OldestCreateTimeByObjectStoreId"][] | null;
12930-
tags?: components["schemas"]["galaxy__util__config_templates__TagCollection"] | null;
12970+
/**
12971+
* Tags
12972+
* @description The collection of tags associated with an item.
12973+
*/
12974+
tags?: string[] | null;
1293112975
/**
1293212976
* Type
1293312977
* @description This is always `collection` for dataset collections.
@@ -13088,7 +13132,11 @@ export interface components {
1308813132
* @description A list of objects containing the object store ID and the oldest creation time of the datasets stored in that object store for this collection.This is used to determine the age of the datasets in the collection when the object store is short-lived.
1308913133
*/
1309013134
store_times_summary?: components["schemas"]["OldestCreateTimeByObjectStoreId"][] | null;
13091-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
13135+
/**
13136+
* Tags
13137+
* @description The collection of tags associated with an item.
13138+
*/
13139+
tags: string[];
1309213140
/**
1309313141
* Type
1309413142
* @description This is always `collection` for dataset collections.
@@ -13228,7 +13276,11 @@ export interface components {
1322813276
* @description A list of objects containing the object store ID and the oldest creation time of the datasets stored in that object store for this collection.This is used to determine the age of the datasets in the collection when the object store is short-lived.
1322913277
*/
1323013278
store_times_summary?: components["schemas"]["OldestCreateTimeByObjectStoreId"][] | null;
13231-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
13279+
/**
13280+
* Tags
13281+
* @description The collection of tags associated with an item.
13282+
*/
13283+
tags: string[];
1323213284
/**
1323313285
* Type
1323413286
* @description This is always `collection` for dataset collections.
@@ -13992,7 +14044,11 @@ export interface components {
1399214044
state_ids: {
1399314045
[key: string]: string[];
1399414046
};
13995-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
14047+
/**
14048+
* Tags
14049+
* @description The collection of tags associated with an item.
14050+
*/
14051+
tags: string[];
1399614052
/**
1399714053
* Update Time
1399814054
* Format: date-time
@@ -14077,7 +14133,11 @@ export interface components {
1407714133
* @description Whether this item has been permanently removed.
1407814134
*/
1407914135
purged: boolean;
14080-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
14136+
/**
14137+
* Tags
14138+
* @description The collection of tags associated with an item.
14139+
*/
14140+
tags: string[];
1408114141
/**
1408214142
* Update Time
1408314143
* Format: date-time
@@ -15495,7 +15555,7 @@ export interface components {
1549515555
* Item tags
1549615556
* @description The list of tags that will replace the current tags associated with the item.
1549715557
*/
15498-
item_tags?: components["schemas"]["TagCollection-Input"] | null;
15558+
item_tags?: string[] | null;
1549915559
};
1550015560
/**
1550115561
* ItemTagsResponse
@@ -16551,7 +16611,11 @@ export interface components {
1655116611
peek: string | null;
1655216612
/** State */
1655316613
state: string;
16554-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
16614+
/**
16615+
* Tags
16616+
* @description The collection of tags associated with an item.
16617+
*/
16618+
tags: string[];
1655516619
/** Update Time */
1655616620
update_time: string;
1655716621
/** Uploaded By */
@@ -17844,7 +17908,11 @@ export interface components {
1784417908
* @description The identifying slug for the page URL, must be unique.
1784517909
*/
1784617910
slug: string;
17847-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
17911+
/**
17912+
* Tags
17913+
* @description The collection of tags associated with an item.
17914+
*/
17915+
tags: string[];
1784817916
/**
1784917917
* Title
1785017918
* @description The name of the page.
@@ -17925,7 +17993,11 @@ export interface components {
1792517993
* @description The identifying slug for the page URL, must be unique.
1792617994
*/
1792717995
slug: string;
17928-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
17996+
/**
17997+
* Tags
17998+
* @description The collection of tags associated with an item.
17999+
*/
18000+
tags: string[];
1792918001
/**
1793018002
* Title
1793118003
* @description The name of the page.
@@ -20625,7 +20697,11 @@ export interface components {
2062520697
| components["schemas"]["ToolStep"]
2062620698
| components["schemas"]["SubworkflowStep"];
2062720699
};
20628-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"];
20700+
/**
20701+
* Tags
20702+
* @description The collection of tags associated with an item.
20703+
*/
20704+
tags: string[];
2062920705
/**
2063020706
* Update Time
2063120707
* Format: date-time
@@ -20730,11 +20806,6 @@ export interface components {
2073020806
* @enum {string}
2073120807
*/
2073220808
SupportedType: "None" | "BasicAuth" | "BearerAuth" | "PassportAuth";
20733-
/**
20734-
* TagCollection
20735-
* @description Represents the collection of tags associated with an item.
20736-
*/
20737-
"TagCollection-Input": string[];
2073820809
/** TagOperationParams */
2073920810
TagOperationParams: {
2074020811
/** Tags */
@@ -21551,7 +21622,7 @@ export interface components {
2155121622
* Tags
2155221623
* @description A list of tags to add to this item.
2155321624
*/
21554-
tags?: components["schemas"]["TagCollection-Input"] | null;
21625+
tags?: string[] | null;
2155521626
/**
2155621627
* Visible
2155721628
* @description Whether this item is visible in the history.
@@ -21578,7 +21649,8 @@ export interface components {
2157821649
published?: boolean | null;
2157921650
/** Purged */
2158021651
purged?: boolean | null;
21581-
tags?: components["schemas"]["TagCollection-Input"] | null;
21652+
/** Tags */
21653+
tags?: string[] | null;
2158221654
};
2158321655
/** UpdateInstancePayload */
2158421656
UpdateInstancePayload: {
@@ -22716,7 +22788,7 @@ export interface components {
2271622788
* Tags
2271722789
* @description A list of tags to add to this item.
2271822790
*/
22719-
tags?: components["schemas"]["galaxy__schema__schema__TagCollection"] | null;
22791+
tags?: string[] | null;
2272022792
/**
2272122793
* Title
2272222794
* @description The name of the visualization.
@@ -22786,7 +22858,7 @@ export interface components {
2278622858
* Tags
2278722859
* @description A list of tags to add to this item.
2278822860
*/
22789-
tags: components["schemas"]["galaxy__schema__schema__TagCollection"] | null;
22861+
tags: string[] | null;
2279022862
/**
2279122863
* Title
2279222864
* @description The name of the visualization.
@@ -23399,16 +23471,6 @@ export interface components {
2339923471
/** URL */
2340023472
url?: string | null;
2340123473
};
23402-
/**
23403-
* TagCollection
23404-
* @description Represents the collection of tags associated with an item.
23405-
*/
23406-
galaxy__schema__schema__TagCollection: string[];
23407-
/**
23408-
* TagCollection
23409-
* @description Represents the collection of tags associated with an item.
23410-
*/
23411-
galaxy__util__config_templates__TagCollection: string[] | null;
2341223474
};
2341323475
responses: never;
2341423476
parameters: never;

lib/galaxy/managers/tags.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def update(self, trans: ProvidesUserContext, payload: ItemTagsPayload) -> None:
4747
"""Apply a new set of tags to an item; previous tags are deleted."""
4848
user = trans.user
4949
new_tags: Optional[str] = None
50-
if payload.item_tags and len(payload.item_tags.root) > 0:
51-
new_tags = ",".join(payload.item_tags.root)
50+
if payload.item_tags:
51+
new_tags = ",".join(payload.item_tags)
5252
item = self._get_item(trans.tag_handler, payload)
5353
trans.tag_handler.delete_item_tags(user, item)
5454
trans.tag_handler.apply_item_tags(user, item, new_tags)

lib/galaxy/schema/schema.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from typing_extensions import (
3232
Literal,
3333
NotRequired,
34+
TypeAlias,
3435
TypedDict,
3536
)
3637

@@ -595,18 +596,15 @@ class HistoryContentSource(str, Enum):
595596
DatasetCollectionInstanceType = Literal["history", "library"]
596597

597598

598-
TagItem = Annotated[str, Field(..., pattern=TAG_ITEM_PATTERN)]
599-
600-
601-
class TagCollection(RootModel):
602-
"""Represents the collection of tags associated with an item."""
603-
604-
root: list[TagItem] = Field(
605-
default=...,
599+
TagItem: TypeAlias = Annotated[str, Field(pattern=TAG_ITEM_PATTERN)]
600+
TagCollection: TypeAlias = Annotated[
601+
list[TagItem],
602+
Field(
606603
title="Tags",
607604
description="The collection of tags associated with an item.",
608605
examples=["COVID-19", "#myFancyTag", "covid19.galaxyproject.org"],
609-
)
606+
),
607+
]
610608

611609

612610
class MetadataFile(Model):

0 commit comments

Comments
 (0)