@@ -8713,3 +8713,96 @@ def test_run_workflow_use_cached_job_format_source_pick_param(self):
87138713 ).strip ()
87148714 == "2"
87158715 )
8716+
8717+ def test_run_workflow_use_cached_job_implicit_conversion_send_to_new_history (self ):
8718+ wf = """class: GalaxyWorkflow
8719+ inputs:
8720+ fastq_input:
8721+ type: data
8722+ steps:
8723+ grep:
8724+ # Grep1 requires fastqsanger, so fastqsanger.gz will be implicitly converted
8725+ tool_id: Grep1
8726+ in:
8727+ input: fastq_input
8728+ """
8729+ with self .dataset_populator .test_history () as history_id :
8730+ # Create a fastqsanger.gz dataset
8731+ compressed_path = self .test_data_resolver .get_filename ("1.fastqsanger.gz" )
8732+ with open (compressed_path , "rb" ) as fh :
8733+ dataset = self .dataset_populator .new_dataset (
8734+ history_id , content = fh , file_type = "fastqsanger.gz" , wait = True
8735+ )
8736+
8737+ # Upload workflow
8738+ workflow_id = self .workflow_populator .upload_yaml_workflow (wf )
8739+
8740+ # Run workflow first time
8741+ workflow_request : Dict [str , Any ] = {
8742+ "inputs" : json .dumps ({"fastq_input" : self ._ds_entry (dataset )}),
8743+ "history" : f"hist_id={ history_id } " ,
8744+ "inputs_by" : "name" ,
8745+ }
8746+ first_invocation_summary = self .workflow_populator .invoke_workflow_and_wait (
8747+ workflow_id , request = workflow_request
8748+ ).json ()
8749+ self .workflow_populator .wait_for_invocation_and_jobs (
8750+ history_id = first_invocation_summary ["history_id" ],
8751+ workflow_id = workflow_id ,
8752+ invocation_id = first_invocation_summary ["id" ],
8753+ assert_ok = True ,
8754+ )
8755+ first_invocation = self .workflow_populator .get_invocation (first_invocation_summary ["id" ], step_details = True )
8756+ first_job_id = first_invocation ["steps" ][1 ]["jobs" ][0 ]["id" ]
8757+ first_job_details = self .dataset_populator .get_job_details (first_job_id , full = True ).json ()
8758+ assert first_job_details ["state" ] == "ok"
8759+ assert not first_job_details ["copied_from_job_id" ]
8760+
8761+ # Verify implicit conversion happened (input to Grep1 should be fastqsanger, not fastqsanger.gz)
8762+ grep_input_id = first_job_details ["inputs" ]["input" ]["id" ]
8763+ grep_input = self .dataset_populator .get_history_dataset_details (
8764+ history_id = first_job_details ["history_id" ], content_id = grep_input_id
8765+ )
8766+ assert grep_input ["extension" ] == "fastqsanger" , "Expected implicit conversion to fastqsanger"
8767+ assert grep_input_id != dataset ["id" ], "Input should be implicitly converted dataset"
8768+
8769+ # Run workflow second time with use_cached_job and new_history_name
8770+ # Remove history parameter since we're specifying new_history_name
8771+ workflow_request .pop ("history" , None )
8772+ workflow_request ["use_cached_job" ] = True
8773+ workflow_request ["new_history_name" ] = self .dataset_populator .get_random_name ()
8774+ second_invocation_response = self .workflow_populator .invoke_workflow (workflow_id , request = workflow_request )
8775+ second_invocation_summary = second_invocation_response .json ()
8776+ second_history_id = second_invocation_summary ["history_id" ]
8777+ # Wait for the workflow to complete
8778+ self .workflow_populator .wait_for_invocation_and_jobs (
8779+ history_id = second_history_id ,
8780+ workflow_id = workflow_id ,
8781+ invocation_id = second_invocation_summary ["id" ],
8782+ assert_ok = True ,
8783+ )
8784+ second_invocation = self .workflow_populator .get_invocation (
8785+ second_invocation_summary ["id" ], step_details = True
8786+ )
8787+ second_job_id = second_invocation ["steps" ][1 ]["jobs" ][0 ]["id" ]
8788+ second_job_details = self .dataset_populator .get_job_details (second_job_id , full = True ).json ()
8789+
8790+ # Verify job was cached
8791+ assert second_job_details ["state" ] == "ok"
8792+ assert second_job_details ["copied_from_job_id" ] == first_job_id , "Second job should be cached from first"
8793+
8794+ # Verify the second invocation is in a different history
8795+ assert (
8796+ second_job_details ["history_id" ] != first_job_details ["history_id" ]
8797+ ), "Second invocation should be in a new history"
8798+
8799+ # Verify implicit conversion dataset was copied to the new history
8800+ cached_grep_input_id = second_job_details ["inputs" ]["input" ]["id" ]
8801+ cached_grep_input = self .dataset_populator .get_history_dataset_details (
8802+ history_id = second_job_details ["history_id" ], content_id = cached_grep_input_id
8803+ )
8804+ assert cached_grep_input ["extension" ] == "fastqsanger"
8805+ # The implicitly converted dataset should have a different HDA ID but same underlying dataset
8806+ assert (
8807+ cached_grep_input_id != grep_input_id
8808+ ), "Cached run should have copied the implicitly converted dataset to the new history"
0 commit comments