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

Refactor models enums to eliminate schema dependency on model layer. #16080

Merged
merged 2 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
126 changes: 63 additions & 63 deletions client/src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,12 @@ export interface components {
* @description Represents a collection of elements contained in the dataset collection.
*/
DatasetCollectionContentElements: components["schemas"]["DCESummary"][];
/**
* DatasetCollectionPopulatedState
* @description An enumeration.
* @enum {string}
*/
DatasetCollectionPopulatedState: "new" | "ok" | "failed";
/**
* DatasetContentType
* @description For retrieving content from a structured dataset (e.g. HDF5)
Expand Down Expand Up @@ -2557,6 +2563,24 @@ export interface components {
* @enum {string}
*/
DatasetSourceType: "hda" | "ldda";
/**
* DatasetState
* @description An enumeration.
* @enum {string}
*/
DatasetState:
| "new"
| "upload"
| "queued"
| "running"
| "ok"
| "empty"
| "error"
| "paused"
| "setting_metadata"
| "failed_metadata"
| "deferred"
| "discarded";
/**
* DatasetStorageDetails
* @description Base model definition with common configuration used by all derived models.
Expand Down Expand Up @@ -2634,6 +2658,12 @@ export interface components {
*/
truncated: boolean;
};
/**
* DatasetValidatedState
* @description An enumeration.
* @enum {string}
*/
DatasetValidatedState: "unknown" | "invalid" | "ok";
/** DatatypeConverter */
DatatypeConverter: {
/**
Expand Down Expand Up @@ -3178,7 +3208,7 @@ export interface components {
* State
* @description The current state of this dataset.
*/
state: components["schemas"]["galaxy__model__Dataset__states"];
state: components["schemas"]["DatasetState"];
/** Tags */
tags: string;
/**
Expand Down Expand Up @@ -3684,7 +3714,7 @@ export interface components {
* State
* @description The current state of this dataset.
*/
state: components["schemas"]["galaxy__model__Dataset__states"];
state: components["schemas"]["DatasetState"];
tags: components["schemas"]["TagCollection"];
/**
* Type
Expand Down Expand Up @@ -3721,7 +3751,7 @@ export interface components {
* Validated State
* @description The state of the datatype validation for this dataset.
*/
validated_state: components["schemas"]["validated_states"];
validated_state: components["schemas"]["DatasetValidatedState"];
/**
* Validated State Message
* @description The message with details about the datatype validation result for this dataset.
Expand Down Expand Up @@ -3772,7 +3802,7 @@ export interface components {
* State
* @description The current state of this dataset.
*/
state: components["schemas"]["galaxy__model__Dataset__states"];
state: components["schemas"]["DatasetState"];
/** Tags */
tags: string[];
};
Expand Down Expand Up @@ -3840,7 +3870,7 @@ export interface components {
* State
* @description The current state of this dataset.
*/
state: components["schemas"]["galaxy__model__Dataset__states"];
state: components["schemas"]["DatasetState"];
tags: components["schemas"]["TagCollection"];
/**
* Type
Expand Down Expand Up @@ -3978,7 +4008,7 @@ export interface components {
* Populated State
* @description Indicates the general state of the elements in the dataset collection:- 'new': new dataset collection, unpopulated elements.- 'ok': collection elements populated (HDAs may or may not have errors).- 'failed': some problem populating, won't be populated.
*/
populated_state: components["schemas"]["populated_states"];
populated_state: components["schemas"]["DatasetCollectionPopulatedState"];
/**
* Populated State Message
* @description Optional message with further information in case the population of the dataset collection failed.
Expand Down Expand Up @@ -4107,7 +4137,7 @@ export interface components {
* Populated State
* @description Indicates the general state of the elements in the dataset collection:- 'new': new dataset collection, unpopulated elements.- 'ok': collection elements populated (HDAs may or may not have errors).- 'failed': some problem populating, won't be populated.
*/
populated_state: components["schemas"]["populated_states"];
populated_state: components["schemas"]["DatasetCollectionPopulatedState"];
/**
* Populated State Message
* @description Optional message with further information in case the population of the dataset collection failed.
Expand Down Expand Up @@ -4531,7 +4561,7 @@ export interface components {
* State
* @description The current state of the History based on the states of the datasets it contains.
*/
state: components["schemas"]["galaxy__model__Dataset__states"];
state: components["schemas"]["DatasetState"];
/**
* State Counts
* @description A dictionary keyed to possible dataset states and valued with the number of datasets in this history that have those states.
Expand Down Expand Up @@ -4683,7 +4713,7 @@ export interface components {
* Populated State
* @description Indicates the general state of the elements in the dataset collection:- 'new': new dataset collection, unpopulated elements.- 'ok': collection elements populated (HDAs may or may not have errors).- 'failed': some problem populating, won't be populated.
*/
populated_state: components["schemas"]["populated_states"];
populated_state: components["schemas"]["DatasetCollectionPopulatedState"];
/**
* States
* @description A dictionary of job states and the number of jobs in that state.
Expand Down Expand Up @@ -4964,7 +4994,7 @@ export interface components {
* State
* @description Current state of the job.
*/
state: components["schemas"]["galaxy__model__Job__states"];
state: components["schemas"]["JobState"];
/**
* Tool ID
* @description Identifier of the tool that generated this job.
Expand Down Expand Up @@ -5003,6 +5033,27 @@ export interface components {
* @enum {string}
*/
JobSourceType: "Job" | "ImplicitCollectionJobs" | "WorkflowInvocation";
/**
* JobState
* @description An enumeration.
* @enum {string}
*/
JobState:
| "new"
| "resubmitted"
| "upload"
| "waiting"
| "queued"
| "running"
| "ok"
| "error"
| "failed"
| "paused"
| "deleting"
| "deleted"
| "stop"
| "stopped"
| "skipped";
/**
* JobStateSummary
* @description Base model definition with common configuration used by all derived models.
Expand All @@ -5025,7 +5076,7 @@ export interface components {
* Populated State
* @description Indicates the general state of the elements in the dataset collection:- 'new': new dataset collection, unpopulated elements.- 'ok': collection elements populated (HDAs may or may not have errors).- 'failed': some problem populating, won't be populated.
*/
populated_state: components["schemas"]["populated_states"];
populated_state: components["schemas"]["DatasetCollectionPopulatedState"];
/**
* States
* @description A dictionary of job states and the number of jobs in that state.
Expand Down Expand Up @@ -7475,7 +7526,7 @@ export interface components {
* Populated State
* @description Indicates the general state of the elements in the dataset collection:- 'new': new dataset collection, unpopulated elements.- 'ok': collection elements populated (HDAs may or may not have errors).- 'failed': some problem populating, won't be populated.
*/
populated_state: components["schemas"]["populated_states"];
populated_state: components["schemas"]["DatasetCollectionPopulatedState"];
/**
* States
* @description A dictionary of job states and the number of jobs in that state.
Expand Down Expand Up @@ -7615,57 +7666,6 @@ export interface components {
*/
namespace: string;
};
/**
* states
* @description An enumeration.
* @enum {string}
*/
galaxy__model__Dataset__states:
| "new"
| "upload"
| "queued"
| "running"
| "ok"
| "empty"
| "error"
| "paused"
| "setting_metadata"
| "failed_metadata"
| "deferred"
| "discarded";
/**
* states
* @description An enumeration.
* @enum {string}
*/
galaxy__model__Job__states:
| "new"
| "resubmitted"
| "upload"
| "waiting"
| "queued"
| "running"
| "ok"
| "error"
| "failed"
| "paused"
| "deleting"
| "deleted"
| "stop"
| "stopped"
| "skipped";
/**
* populated_states
* @description An enumeration.
* @enum {string}
*/
populated_states: "new" | "ok" | "failed";
/**
* validated_states
* @description An enumeration.
* @enum {string}
*/
validated_states: "unknown" | "invalid" | "ok";
};
responses: never;
parameters: never;
Expand Down
58 changes: 10 additions & 48 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@
from galaxy.model.orm.now import now
from galaxy.model.orm.util import add_object_to_object_session
from galaxy.objectstore import ObjectStore
from galaxy.schema.schema import (
DatasetCollectionPopulatedState,
DatasetState,
DatasetValidatedState,
JobState,
)
from galaxy.security import get_permitted_actions
from galaxy.security.idencoding import IdEncodingHelper
from galaxy.security.validate_user_input import validate_password_str
Expand Down Expand Up @@ -1299,22 +1305,7 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable):
_numeric_metric = JobMetricNumeric
_text_metric = JobMetricText

class states(str, Enum):
NEW = "new"
RESUBMITTED = "resubmitted"
UPLOAD = "upload"
WAITING = "waiting"
QUEUED = "queued"
RUNNING = "running"
OK = "ok"
ERROR = "error"
FAILED = "failed"
PAUSED = "paused"
DELETING = "deleting"
DELETED = "deleted"
STOPPING = "stop"
STOPPED = "stopped"
SKIPPED = "skipped"
states = JobState

terminal_states = [states.OK, states.ERROR, states.DELETED]
#: job states where the job hasn't finished and the model may still change
Expand Down Expand Up @@ -3739,31 +3730,8 @@ class Dataset(Base, StorableObject, Serializable):
back_populates="dataset",
)

class states(str, Enum):
NEW = "new"
UPLOAD = "upload"
QUEUED = "queued"
RUNNING = "running"
OK = "ok"
EMPTY = "empty"
ERROR = "error"
PAUSED = "paused"
SETTING_METADATA = "setting_metadata"
FAILED_METADATA = "failed_metadata"
# Non-deleted, non-purged datasets that don't have physical files.
# These shouldn't have objectstores attached -
# 'deferred' can be materialized for jobs using
# attached DatasetSource objects but 'discarded'
# cannot (e.g. imported histories). These should still
# be able to have history contents associated (normal HDAs?)
DEFERRED = "deferred"
DISCARDED = "discarded"

@classmethod
def values(self):
return self.__members__.values()

# failed_metadata is only valid as DatasetInstance state currently
states = DatasetState

non_ready_states = (states.NEW, states.UPLOAD, states.QUEUED, states.RUNNING, states.SETTING_METADATA)
ready_states = tuple(set(states.__members__.values()) - set(non_ready_states))
Expand Down Expand Up @@ -4190,10 +4158,7 @@ class DatasetInstance(UsesCreateAndUpdateTime, _HasTable):
purged: bool
creating_job_associations: List[Union[JobToOutputDatasetCollectionAssociation, JobToOutputDatasetAssociation]]

class validated_states(str, Enum):
UNKNOWN = "unknown"
INVALID = "invalid"
OK = "ok"
validated_states = DatasetValidatedState

def __init__(
self,
Expand Down Expand Up @@ -5963,10 +5928,7 @@ class DatasetCollection(Base, Dictifiable, UsesAnnotations, Serializable):
dict_collection_visible_keys = ["id", "collection_type"]
dict_element_visible_keys = ["id", "collection_type"]

class populated_states(str, Enum):
NEW = "new" # New dataset collection, unpopulated elements
OK = "ok" # Collection elements populated (HDAs may or may not have errors)
FAILED = "failed" # some problem populating state, won't be populated
populated_states = DatasetCollectionPopulatedState

def __init__(self, id=None, collection_type=None, populated=True, element_count=None):
self.id = id
Expand Down
Loading