-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lava_dispatcher: Make Pipeline
job
attribute always be Job
Right now the that attribute can be None but only when running in unit tests. Instead of having special behavior for unit tests change the unit tests to properly initialize the Pipeline objects. Changes to classes: Pipeline __init__ First argument is now `job` and is required to be job. `job` is assigned to the attribute. Job __init__ `device` and `timeout` are now required arguments. They are assigned to attributes. To properly initialize the Job objects inside unit tests a new method was added to the `LavaDispatcherTestCase` called `create_simple_job`. The eventual goal is to make dispatcher pass the `mypy --strict` type checking. Unfortunately the pytest does not support static typing so all the unit tests that had to be changed were converted to unittest style tests. See pytest this developer comment: pytest-dev/pytest#5981 (comment)
- Loading branch information
Igor Ponomarev
committed
Jan 25, 2024
1 parent
8a8a79f
commit c53746d
Showing
25 changed files
with
2,268 additions
and
2,001 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# Author: Neil Williams <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
from __future__ import annotations | ||
|
||
import datetime | ||
import errno | ||
|
@@ -11,6 +12,7 @@ | |
import tempfile | ||
import time | ||
import traceback | ||
from typing import TYPE_CHECKING | ||
|
||
import pytz | ||
|
||
|
@@ -23,6 +25,14 @@ | |
MultinodeProtocol, | ||
) | ||
|
||
if TYPE_CHECKING: | ||
from logging import Logger | ||
from typing import Any | ||
|
||
from lava_common.timeout import Timeout | ||
|
||
from .device import Device | ||
|
||
|
||
class Job: | ||
""" | ||
|
@@ -40,17 +50,24 @@ class Job: | |
device for this job - one job, one device. | ||
""" | ||
|
||
def __init__(self, job_id, parameters, logger): | ||
def __init__( | ||
self, | ||
job_id: int, | ||
parameters: dict[str, Any], | ||
logger: Logger, | ||
device: Device, | ||
timeout: Timeout, | ||
): | ||
self.job_id = job_id | ||
self.logger = logger | ||
self.device = None | ||
self.device = device | ||
self.parameters = parameters | ||
self.__context__ = PipelineContext() | ||
self.pipeline = None | ||
self.connection = None | ||
self.triggers = [] # actions can add trigger strings to the run a diagnostic | ||
self.diagnostics = [DiagnoseNetwork] | ||
self.timeout = None | ||
self.timeout = timeout | ||
self.protocols = [] | ||
self.compatibility = 2 | ||
# Was the job cleaned | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (C) 2023 Collabora Limited | ||
# | ||
# Author: Igor Ponomarev <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-2.0-or-later |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (C) 2023 Collabora Limited | ||
# | ||
# Author: Igor Ponomarev <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-2.0-or-later |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (C) 2023 Collabora Limited | ||
# | ||
# Author: Igor Ponomarev <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-2.0-or-later |
Oops, something went wrong.