Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escaping: Escape characters +-&|!(){}[]^"~*?:\ with \, e.g. \+
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Hi, I Encounter A Weird Behavior: I Have A Task A That Schedules A Task B. Task B Is Executed On An Agent, But With An Old Commit

Hi, I encounter a weird behavior: I have a task A that schedules a task B. Task B is executed on an agent, but with an old commit 🤔 although the branch is pushed, the agent does not retrieve the last version

Posted 3 years ago
Votes Newest

Answers 12

How did you create task B? cloned from other task?

The agent will run the task according to the commit in the execution tab (you can choose commit, branch or tag)

Posted 3 years ago

In execution tab, I see old commit, in logs, I see an empty branch and the old commit

Posted 3 years ago

Hi JitteryCoyote63 , what commit and branch do you see in the UI?

Posted 3 years ago

The task is created using Task.clone() yes

Posted 3 years ago

here is the function used to create the task:

` def schedule_task(parent_task: Task,
task_type: str = None,
entry_point: str = None,
force_requirements: List[str] = None,
working_dir: str = ".",
wait_for_status: bool = False,
raise_on_status: Iterable[Task.TaskStatusEnum] = (Task.TaskStatusEnum.failed, Task.TaskStatusEnum.stopped),
task_name: str = None,
reuse_if_exists: bool = False) -> Task:
Schedule a Task to be executed remotely in a trains-agent.

    parent_task (Task): Parent Task of the task to be scheduled.
    task_type (str, optional): Type of the task to be scheduled. Defaults to None.
    entry_point (str, optional): Entry point of the task to be scheduled. Defaults to None.
    working_dir (str, optional): Working directory of the task to be scheduled. Defaults to None.
    force_requirements (List[str], optional): List of requirements overwriting the ones from the parent task. Defaults to None.
    queue_name (str, optional): Queue where to send the task to be scheduled. Defaults to "default".
    extra_params (dict, optional): Extra parameters sent to the task using connect().
    wait_for_status (bool, optional): Wait for task to finish. Defaults to False.
    raise_on_status (Tuple[Task.TaskStatusEnum], optional): Task status to consider for raising an error. Defaults to (failed, stopped)
    task_name (str, optional): Name of the task. Defaults to parent task name.
    reuse_if_exists (bool, optional): Return the task if it already exists and is completed instead of running it.

    Task: The task successfully enqueued.
if reuse_if_exists and task_name is not None:
    task: Task = Task.get_task(project_name=parent_task.get_project_name(), task_name=task_name)
    if task is not None and task.status == Task.TaskStatusEnum.completed:
        return task

# TODO: Extend and use trains.automation.TrainsJob class
cloned_task = Task.clone(parent_task, name=task_name, parent=parent_task.task_id)

if task_type is not None:

script = cloned_task.data.script

if entry_point is not None:
    script.entry_point = entry_point

if working_dir is not None:
    script.working_dir = working_dir

if force_requirements is not None:
    # Trains correctly guess environment, except from this package itself.
    # Therefore requirements are overwritten.
    # Explicitly setting torch version here will let trains pick the right wheel
    # Based on trains-agent CUDA version.

if extra_params is not None:

Task.enqueue(cloned_task, queue_name=queue_name)

parent_task.get_logger().report_text(f"Successfully scheduled {task_type} Task (id={cloned_task.task_id})")

if wait_for_status:

return cloned_task `
Posted 3 years ago

Great 🙂

If you do wanna change the commit/branch/tag, you can change it from the data.script section in the cloned_task object

Posted 3 years ago

It should create task B with the same commit as task A in this scenario, do you have different commits?

Posted 3 years ago

The task I cloned from is not the one I though

Posted 3 years ago

ho wait, actually I am wrong

Posted 3 years ago


Posted 3 years ago

It indeed has the old commit, so they match, no problem actually 🙂

Posted 3 years ago

for some reason when cloning task A, trains sets an old commit in task B. I tried to recreate task A to enforce a new task id and new commit id, but still the same issue

Posted 3 years ago
12 Answers
3 years ago
one year ago
Similar posts