Skip to content

Commit

Permalink
fix(workflow): set plan creation date to activity start date (#3210)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-alisafaee committed Nov 15, 2022
1 parent 008ae71 commit c18f85c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion renku/command/run.py
Expand Up @@ -204,7 +204,9 @@ def parse_explicit_definition(entries, type):
if not creators:
creators = [cast(Person, get_git_user(project_context.repository))]

plan = tool.to_plan(name=name, description=description, keywords=keyword, creators=creators)
plan = tool.to_plan(
name=name, description=description, keywords=keyword, creators=creators, date_created=started_at_time
)
activity = Activity.from_plan(
plan=plan,
repository=project_context.repository,
Expand Down
3 changes: 3 additions & 0 deletions renku/core/workflow/plan_factory.py
Expand Up @@ -22,6 +22,7 @@
import shlex
import time
from contextlib import contextmanager
from datetime import datetime
from itertools import chain
from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Union, cast
Expand Down Expand Up @@ -701,11 +702,13 @@ def to_plan(
description: Optional[str] = None,
keywords: Optional[List[str]] = None,
creators: Optional[List[Person]] = None,
date_created: Optional[datetime] = None,
) -> Plan:
"""Return an instance of ``Plan`` based on this factory."""
plan = Plan(
id=self.plan_id,
name=name,
date_created=date_created,
description=description,
keywords=keywords,
command=" ".join(self.base_command),
Expand Down
14 changes: 14 additions & 0 deletions tests/cli/test_workflow.py
Expand Up @@ -1450,3 +1450,17 @@ def test_rerun_doesnt_update_plan_index(runner, project, with_injection):
assert 0 == result.exit_code, format_result_exception(result)
assert new_description in result.output
assert original_description not in result.output


def test_plan_creation_date(runner, project, with_injection):
"""Test Plan's creation date is before Activity's start date."""
result = runner.invoke(cli, ["run", "--name", "r1", "--no-output", "sleep", "2"])
assert 0 == result.exit_code, format_result_exception(result)

with with_injection():
plan_gateway = PlanGateway()
plan = plan_gateway.get_by_name("r1")
activity_gateway = ActivityGateway()
activity = activity_gateway.get_all_activities()[0]

assert plan.date_created <= activity.started_at_time

0 comments on commit c18f85c

Please sign in to comment.