riga / law

Build large-scale task workflows: luigi + job submission + remote targets + environment sandboxing using Docker/Singularity
http://law.readthedocs.io
BSD 3-Clause "New" or "Revised" License
96 stars 39 forks source link

How to handle workflows that could have an empty branchmap? #179

Closed HerrHorizontal closed 1 month ago

HerrHorizontal commented 1 month ago

Question

It happens in one of my projects that in a workflow without further dependencies due to evaluations at runtime these might be empty workflows, meaning they return an empty branch map. It seems however, that this breaks the current implementation at some point with an error trace

Traceback (most recent call last):
  File "/work/mhorzela/mc-run/luigi/luigi/retcodes.py", line 75, in run_with_retcodes
    worker = luigi.interface._run(argv).worker
  File "/work/mhorzela/mc-run/luigi/luigi/interface.py", line 217, in _run
    return _schedule_and_run([cp.get_task_obj()], worker_scheduler_factory)
  File "/work/mhorzela/mc-run/luigi/luigi/cmdline_parser.py", line 114, in get_task_obj
    return self._get_task_cls()(**self._get_task_kwargs())
  File "/work/mhorzela/mc-run/law/law/task/base.py", line 374, in __call__
    skip_abort = getattr(inst, "_" + param)(value)
  File "/work/mhorzela/mc-run/law/law/task/base.py", line 642, in _print_status
    return print_task_status(self, *args)
  File "/work/mhorzela/mc-run/law/law/task/interactive.py", line 261, in print_task_status
    dep.output(),
  File "/work/mhorzela/mc-run/law/law/workflow/remote.py", line 533, in output
    task.control_output_postfix(),
  File "/work/mhorzela/mc-run/law/law/workflow/remote.py", line 1478, in control_output_postfix
    return self.get_branches_repr()
  File "/work/mhorzela/mc-run/law/law/workflow/base.py", line 1341, in get_branches_repr
    return "{}To{}".format(min(branch_map.keys()), max(branch_map.keys()) + 1)
ValueError: min() arg is an empty sequence

Is there a way to handle this? If not yet in law, can this be catched?

In my opinion an empty workflow should be in principle a valid usecase.

riga commented 1 month ago

Hi @HerrHorizontal ,

thanks for the stack trace. I agree, this should be a valid use case. Looking into this.

riga commented 1 month ago

Could you check if the changes on the fix/empty_workflows branch work for you?

HerrHorizontal commented 1 month ago

Yes, works

riga commented 1 month ago

Great, merging to master then.