Skip to content

[Bug]: Workflow._get_representative_launch does not return the most recent completed launch #577

Description

@thoschr

Code snippet

import datetime
from fireworks.core.firework import Firework, Launch, Workflow

UTC = datetime.timezone.utc
launch_dir = "." 

completed_1 = Launch(
    state="COMPLETED",
    launch_dir=launch_dir,
    state_history=[{"state": "COMPLETED", "created_on": datetime.datetime(2020, 1, 1, tzinfo=UTC)}],
)
completed_2 = Launch(
    state="COMPLETED",
    launch_dir=launch_dir,
    state_history=[{"state": "COMPLETED", "created_on": datetime.datetime(2021, 1, 1, tzinfo=UTC)}],
)
running = Launch(state="RUNNING", launch_dir=launch_dir)

fw = Firework("fireworks.core.firework.FiretaskBase", launches=[running, completed_1, completed_2])

result = Workflow._get_representative_launch(fw)
print("returned launch time_end:", result.time_end)
print("expected (most recent):  ", completed_2.time_end)
assert result is completed_2, f"BUG: expected completed_2 (most recent) but got the one with time_end={result.time_end}"
print("OK - no bug")

What happened?

I want to use Workflow._get_representative_launch to get the most recent completed launch among several completed launches. A bug in the code leads to that the first completed launch is returned instead.

Version

v2.1.4 at commit 7168655

Which OS?

  • MacOS
  • Windows
  • Linux

Log output

returned launch time_end: 2020-01-01 00:00:00+00:00
expected (most recent):   2021-01-01 00:00:00+00:00
Traceback (most recent call last):
  File "/home/thoschr/testing/fireworks/bug/test.py", line 24, in <module>
    assert result is completed_2, f"BUG: expected completed_2 (most recent) but got the one with time_end={result.time_end}"
           ^^^^^^^^^^^^^^^^^^^^^
AssertionError: BUG: expected completed_2 (most recent) but got the one with time_end=2020-01-01 00:00:00+00:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions