Skip to content

Commit

Permalink
Implement {src: "url"} on the new request API...
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Sep 10, 2024
1 parent a563c0f commit 64e64be
Show file tree
Hide file tree
Showing 19 changed files with 571 additions and 96 deletions.
78 changes: 46 additions & 32 deletions doc/source/dev/tool_state_state_classes.plantuml.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 16 additions & 7 deletions doc/source/dev/tool_state_state_classes.plantuml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,45 @@ package galaxy.tool_util.parameters.state {
class ToolState {
state_representation: str
input_state: Dict[str, Any]
+ validate(input_models: ToolParameterBundle)
+ {abstract} _to_base_model(input_models: ToolParameterBundle): Optional[Type[BaseModel]]
+ validate(parameters: ToolParameterBundle)
+ {abstract} _to_base_model(parameters: ToolParameterBundle): Optional[Type[BaseModel]]
}

class RequestToolState {
state_representation = "request"
+ _to_base_model(input_models: ToolParameterBundle): Type[BaseModel]
+ _to_base_model(parameters: ToolParameterBundle): Type[BaseModel]
}
note bottom: Object references of the form \n{src: "hda", id: <encoded_id>}.\n Allow mapping/reduce constructs.

class RequestInternalToolState {
state_representation = "request_internal"
+ _to_base_model(input_models: ToolParameterBundle): Type[BaseModel]
+ _to_base_model(parameters: ToolParameterBundle): Type[BaseModel]
}
note bottom: Object references of the form \n{src: "hda", id: <decoded_id>}.\n Allow mapping/reduce constructs.
note bottom: Object references of the form \n{src: "hda", id: <decoded_id>}.\n Allow mapping/reduce constructs. Allows URI src dicts.

class RequestInternalDereferencedToolState {
state_representation = "request_internal"
+ _to_base_model(parameters: ToolParameterBundle): Type[BaseModel]
}
note bottom: Object references of the form \n{src: "hda", id: <decoded_id>}.\n Allow mapping/reduce constructs. No URI src dicts - all converted to HDAs.

class JobInternalToolState {
state_representation = "job_internal"
+ _to_base_model(input_models: ToolParameterBundle): Type[BaseModel]
+ _to_base_model(parameters: ToolParameterBundle): Type[BaseModel]

}
note bottom: Object references of the form \n{src: "hda", id: <decoded_id>}.\n Mapping constructs expanded out.\n (Defaults are inserted?)

ToolState <|-- RequestToolState
ToolState <|-- RequestInternalToolState
ToolState <|-- RequestInternalDereferencedToolState
ToolState <|-- JobInternalToolState

RequestToolState - RequestInternalToolState : decode >

RequestInternalToolState o-- JobInternalToolState : expand >
RequestInternalToolState - RequestInternalDereferencedToolState : dereference >

RequestInternalDereferencedToolState o-- JobInternalToolState : expand >

}
@enduml
62 changes: 62 additions & 0 deletions doc/source/dev/tool_state_task.plantuml.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions doc/source/dev/tool_state_task.plantuml.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@startuml
'!include plantuml_options.txt
queue TaskQueue as queue
participant "queue_jobs Task" as task
participant "JobSubmitter.queue_jobs" as queue_jobs
participant "JobSubmitter.dereference" as dereference
participant "materialize Task" as materialize_task
participant "Tool.handle_input_async" as handle_input
participant "expand_meta_parameters_async" as expand
participant "ToolAction.execute" as tool_action

queue -> task : <Launch Task>
task -> queue_jobs : QueueJobs pydantic model
queue_jobs -> dereference : RequestInternalToolState
dereference -> queue_jobs : RequestInternalDereferencedToolState
queue_jobs -> materialize_task : HDA (with state deferred)
materialize_task -> queue_jobs : return when state is okay
queue_jobs -> handle_input : RequestInternalDereferencedToolState
handle_input -> expand : RequestInternalDereferencedToolState
expand -> handle_input : JobInternalToolState[]
loop over expanded job tool states
handle_input -> tool_action :
tool_action -> handle_input : A Galaxy Job
end
@enduml
7 changes: 4 additions & 3 deletions lib/galaxy/managers/hdas.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def create(
session.commit()
return hda

def materialize(self, request: MaterializeDatasetInstanceTaskRequest) -> None:
def materialize(self, request: MaterializeDatasetInstanceTaskRequest, in_place: bool = False) -> None:
request_user: RequestUser = request.user
materializer = materializer_factory(
True, # attached...
Expand All @@ -187,8 +187,9 @@ def materialize(self, request: MaterializeDatasetInstanceTaskRequest) -> None:
else:
dataset_instance = self.ldda_manager.get_accessible(request.content, user)
history = self.app.history_manager.by_id(request.history_id)
new_hda = materializer.ensure_materialized(dataset_instance, target_history=history)
history.add_dataset(new_hda, set_hid=True)
new_hda = materializer.ensure_materialized(dataset_instance, target_history=history, in_place=in_place)
if not in_place:
history.add_dataset(new_hda, set_hid=True)
session = self.session()
with transaction(session):
session.commit()
Expand Down
Loading

0 comments on commit 64e64be

Please sign in to comment.