complete_on_downloads for task block (#403)
This commit is contained in:
@@ -68,3 +68,13 @@ def zip_files(files_path: str, zip_file_path: str) -> str:
|
||||
|
||||
def get_path_for_workflow_download_directory(workflow_run_id: str) -> Path:
|
||||
return Path(f"{REPO_ROOT_DIR}/downloads/{workflow_run_id}/")
|
||||
|
||||
|
||||
def get_number_of_files_in_directory(directory: Path, recursive: bool = False) -> int:
|
||||
count = 0
|
||||
for root, dirs, files in os.walk(directory):
|
||||
if not recursive:
|
||||
count += len(files)
|
||||
break
|
||||
count += len(files)
|
||||
return count
|
||||
|
||||
@@ -217,7 +217,7 @@ class WorkflowRunContext:
|
||||
self, parameter: OutputParameter, value: dict[str, Any] | list | str | None
|
||||
) -> None:
|
||||
if parameter.key in self.values:
|
||||
LOG.error(f"Output parameter {parameter.output_parameter_id} already has a registered value")
|
||||
LOG.warning(f"Output parameter {parameter.output_parameter_id} already has a registered value")
|
||||
return
|
||||
|
||||
self.values[parameter.key] = value
|
||||
|
||||
@@ -71,6 +71,14 @@ class Block(BaseModel, abc.ABC):
|
||||
workflow_run_id: str,
|
||||
value: dict[str, Any] | list | str | None = None,
|
||||
) -> None:
|
||||
if workflow_run_context.has_value(self.output_parameter.key):
|
||||
LOG.warning(
|
||||
"Output parameter value already recorded",
|
||||
output_parameter_id=self.output_parameter.output_parameter_id,
|
||||
workflow_run_id=workflow_run_id,
|
||||
)
|
||||
return
|
||||
|
||||
await workflow_run_context.register_output_parameter_value_post_execution(
|
||||
parameter=self.output_parameter,
|
||||
value=value,
|
||||
@@ -150,6 +158,7 @@ class TaskBlock(Block):
|
||||
max_retries: int = 0
|
||||
max_steps_per_run: int | None = None
|
||||
parameters: list[PARAMETER_TYPE] = []
|
||||
complete_on_download: bool = False
|
||||
|
||||
def get_all_parameters(
|
||||
self,
|
||||
@@ -265,6 +274,7 @@ class TaskBlock(Block):
|
||||
task=task,
|
||||
step=step,
|
||||
workflow_run=workflow_run,
|
||||
complete_on_download=self.complete_on_download,
|
||||
)
|
||||
except Exception as e:
|
||||
# Make sure the task is marked as failed in the database before raising the exception
|
||||
|
||||
@@ -87,6 +87,7 @@ class TaskBlockYAML(BlockYAML):
|
||||
max_retries: int = 0
|
||||
max_steps_per_run: int | None = None
|
||||
parameter_keys: list[str] | None = None
|
||||
complete_on_download: bool = False
|
||||
|
||||
|
||||
class ForLoopBlockYAML(BlockYAML):
|
||||
|
||||
@@ -969,6 +969,7 @@ class WorkflowService:
|
||||
error_code_mapping=block_yaml.error_code_mapping,
|
||||
max_steps_per_run=block_yaml.max_steps_per_run,
|
||||
max_retries=block_yaml.max_retries,
|
||||
complete_on_download=block_yaml.complete_on_download,
|
||||
)
|
||||
elif block_yaml.block_type == BlockType.FOR_LOOP:
|
||||
loop_blocks = [
|
||||
|
||||
Reference in New Issue
Block a user