Skip to content

Commit c18f85c

Browse files
fix(workflow): set plan creation date to activity start date (#3210)
1 parent 008ae71 commit c18f85c

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

renku/command/run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ def parse_explicit_definition(entries, type):
204204
if not creators:
205205
creators = [cast(Person, get_git_user(project_context.repository))]
206206

207-
plan = tool.to_plan(name=name, description=description, keywords=keyword, creators=creators)
207+
plan = tool.to_plan(
208+
name=name, description=description, keywords=keyword, creators=creators, date_created=started_at_time
209+
)
208210
activity = Activity.from_plan(
209211
plan=plan,
210212
repository=project_context.repository,

renku/core/workflow/plan_factory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import shlex
2323
import time
2424
from contextlib import contextmanager
25+
from datetime import datetime
2526
from itertools import chain
2627
from pathlib import Path
2728
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Union, cast
@@ -701,11 +702,13 @@ def to_plan(
701702
description: Optional[str] = None,
702703
keywords: Optional[List[str]] = None,
703704
creators: Optional[List[Person]] = None,
705+
date_created: Optional[datetime] = None,
704706
) -> Plan:
705707
"""Return an instance of ``Plan`` based on this factory."""
706708
plan = Plan(
707709
id=self.plan_id,
708710
name=name,
711+
date_created=date_created,
709712
description=description,
710713
keywords=keywords,
711714
command=" ".join(self.base_command),

tests/cli/test_workflow.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,3 +1450,17 @@ def test_rerun_doesnt_update_plan_index(runner, project, with_injection):
14501450
assert 0 == result.exit_code, format_result_exception(result)
14511451
assert new_description in result.output
14521452
assert original_description not in result.output
1453+
1454+
1455+
def test_plan_creation_date(runner, project, with_injection):
1456+
"""Test Plan's creation date is before Activity's start date."""
1457+
result = runner.invoke(cli, ["run", "--name", "r1", "--no-output", "sleep", "2"])
1458+
assert 0 == result.exit_code, format_result_exception(result)
1459+
1460+
with with_injection():
1461+
plan_gateway = PlanGateway()
1462+
plan = plan_gateway.get_by_name("r1")
1463+
activity_gateway = ActivityGateway()
1464+
activity = activity_gateway.get_all_activities()[0]
1465+
1466+
assert plan.date_created <= activity.started_at_time

0 commit comments

Comments
 (0)