Skip to content

Commit

Permalink
squash: fix conflicts, and undoing most of the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Nov 14, 2023
1 parent d8bc6c5 commit 8b81a3b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 29 deletions.
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ def _load_theme(

# Autodocs & type hints
autodoc_default_flags = ['members', 'undoc-members', 'show-inheritance', 'private-members']
autodoc_default_options = {
# Enable to "ignore" re-imported names in `tmt.__all__`
'ignore-module-all': True
}
autoclass_content = "both"

autodoc_typehints_format = 'short'
Expand Down
9 changes: 5 additions & 4 deletions plans/install/docs.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ prepare:
- python3-docutils
execute:
script: |
set -ex -o pipefail
pip install hatch
make docs 2>&1 | tee output
grep -E 'ERROR|WARNING' output | grep -v 'more than one target found for cross-reference' && exit 1 || exit 0
set -ex
set -o pipefail
pip3 install .[docs]
make -C docs html 2>&1 | tee output
egrep 'ERROR|WARNING' output && exit 1 || exit 0
10 changes: 5 additions & 5 deletions tmt/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
if TYPE_CHECKING:
from typing_extensions import Self

import tmt.steps.provision
from tmt.steps.provision import Guest


TaskT = TypeVar('TaskT', bound='_Task')
Expand All @@ -33,7 +33,7 @@ class TaskOutcome(Generic[TaskT]):

#: Guest on which the phase was executed. May be unset, some tasks
#: may handle multiguest actions on their own.
guest: Optional['tmt.steps.provision.Guest']
guest: Optional['Guest']

#: If set, an exception was raised by the running task, and the exception
#: is saved in this field.
Expand All @@ -45,7 +45,7 @@ class _Task:
""" A base class for tasks to be executed on one or more guests """

#: A list of guests to execute the task on.
guests: list['tmt.steps.provision.Guest']
guests: list['Guest']

#: A logger to use for logging events related to the task. It serves as
#: a root logger for new loggers queue may spawn for each guest.
Expand Down Expand Up @@ -115,7 +115,7 @@ def go(self) -> Iterator[TaskOutcome['Self']]:
class Task(_Task):
""" A task that should run on multiple guests at the same time """

def run_on_guest(self, guest: 'tmt.steps.provision.Guest', logger: Logger) -> None:
def run_on_guest(self, guest: 'Guest', logger: Logger) -> None:
raise NotImplementedError

def prepare_loggers(
Expand Down Expand Up @@ -157,7 +157,7 @@ def go(self) -> Iterator[TaskOutcome['Self']]:
old_loggers: dict[str, Logger] = {}

with ThreadPoolExecutor(max_workers=len(self.guests)) as executor:
futures: dict[Future[None], 'tmt.steps.provision.Guest'] = {}
futures: dict[Future[None], 'Guest'] = {}

for guest in self.guests:
# Swap guest's logger for the one we prepared, with labels
Expand Down
31 changes: 16 additions & 15 deletions tmt/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
import tmt.plugins
import tmt.steps.discover
import tmt.steps.execute
import tmt.steps.provision
from tmt.base import Plan
from tmt.steps.provision import Guest


DEFAULT_PLUGIN_METHOD_ORDER: int = 50
Expand Down Expand Up @@ -176,7 +177,7 @@ def __init__(
super().__init__(**kwargs)
self.order: int = order

def enabled_on_guest(self, guest: 'tmt.steps.provision.Guest') -> bool:
def enabled_on_guest(self, guest: 'Guest') -> bool:
""" Phases are enabled across all guests by default """
return True

Expand Down Expand Up @@ -330,7 +331,7 @@ class Step(tmt.utils.MultiInvokableCommon, tmt.export.Exportable['Step']):
def __init__(
self,
*,
plan: 'tmt.base.Plan',
plan: 'Plan',
data: Optional[RawStepDataArgument] = None,
name: Optional[str] = None,
workdir: tmt.utils.WorkdirArgumentType = None,
Expand All @@ -341,7 +342,7 @@ def __init__(
super().__init__(name=name, parent=plan, workdir=workdir, logger=logger)

# Initialize data
self.plan: 'tmt.base.Plan' = plan
self.plan: 'Plan' = plan
self._status: Optional[str] = None
self._phases: list[Phase] = []

Expand Down Expand Up @@ -1361,7 +1362,7 @@ def _emit_key(key: str) -> None:
for key in keys:
_emit_key(key)

def enabled_on_guest(self, guest: 'tmt.steps.provision.Guest') -> bool:
def enabled_on_guest(self, guest: 'Guest') -> bool:
""" Check if the plugin is enabled on the specific guest """

# FIXME: cast() - typeless "dispatcher" method
Expand Down Expand Up @@ -1464,7 +1465,7 @@ class Plugin(BasePlugin[StepDataT]):
def go(
self,
*,
guest: 'tmt.steps.provision.Guest',
guest: 'Guest',
environment: Optional[tmt.utils.EnvironmentType] = None,
logger: tmt.log.Logger) -> None:
""" Perform actions shared among plugins when beginning their tasks """
Expand Down Expand Up @@ -1739,7 +1740,7 @@ class GuestTopology(SerializableContainer):
role: Optional[str]
hostname: Optional[str]

def __init__(self, guest: 'tmt.steps.provision.Guest') -> None:
def __init__(self, guest: 'Guest') -> None:
self.name = guest.name
self.role = guest.role
self.hostname = guest.guest
Expand All @@ -1757,8 +1758,8 @@ class Topology(SerializableContainer):
role_names: list[str]
roles: dict[str, list[str]]

def __init__(self, guests: list['tmt.steps.provision.Guest']) -> None:
roles: collections.defaultdict[str, list['tmt.steps.provision.Guest']] = \
def __init__(self, guests: list['Guest']) -> None:
roles: collections.defaultdict[str, list['Guest']] = \
collections.defaultdict(list)

self.guest = None
Expand Down Expand Up @@ -1904,7 +1905,7 @@ def push(
self,
*,
dirpath: Path,
guest: 'tmt.steps.provision.Guest',
guest: 'Guest',
filename_base: Optional[Path] = None,
logger: tmt.log.Logger) -> EnvironmentType:
"""
Expand Down Expand Up @@ -1966,7 +1967,7 @@ def run(self, logger: tmt.log.Logger) -> None:

self.phase.go()

def run_on_guest(self, guest: 'tmt.steps.provision.Guest', logger: tmt.log.Logger) -> None:
def run_on_guest(self, guest: 'Guest', logger: tmt.log.Logger) -> None:
assert isinstance(self.phase, Plugin) # narrow type

self.phase.go(
Expand All @@ -1989,7 +1990,7 @@ def enqueue(
self,
*,
phase: Union[Action, Plugin[StepDataT]],
guests: list['tmt.steps.provision.Guest']) -> None:
guests: list['Guest']) -> None:
"""
Add a phase to queue.
Expand Down Expand Up @@ -2018,7 +2019,7 @@ class PushTask(Task):
def name(self) -> str:
return 'push'

def run_on_guest(self, guest: 'tmt.steps.provision.Guest', logger: tmt.log.Logger) -> None:
def run_on_guest(self, guest: 'Guest', logger: tmt.log.Logger) -> None:
guest.push()


Expand All @@ -2032,7 +2033,7 @@ class PullTask(Task):
def name(self) -> str:
return 'pull'

def run_on_guest(self, guest: 'tmt.steps.provision.Guest', logger: tmt.log.Logger) -> None:
def run_on_guest(self, guest: 'Guest', logger: tmt.log.Logger) -> None:
guest.pull(source=self.source)


Expand Down Expand Up @@ -2080,7 +2081,7 @@ def sync_with_guests(
from failed_actions[0].exc


def safe_filename(basename: str, phase: Phase, guest: 'tmt.steps.provision.Guest') -> Path:
def safe_filename(basename: str, phase: Phase, guest: 'Guest') -> Path:
"""
Construct a non-conflicting filename safe for parallel tasks.
Expand Down
9 changes: 5 additions & 4 deletions tmt/steps/discover/fmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,15 @@ class DiscoverFmf(tmt.steps.discover.DiscoverPlugin[DiscoverFmfStepData]):
dist-git-source: true
Related config options (all optional):
* dist-git-merge - set to True if you want to copy in extracted
sources to the local repo
sources to the local repo
* dist-git-init - set to True and 'fmf init' will be called inside
extracted sources (at dist-git-extract or top directory)
extracted sources (at dist-git-extract or top directory)
* dist-git-extract - directory (glob supported) to copy from
extracted sources (defaults to inner fmf-root)
extracted sources (defaults to inner fmf-root)
* dist-git-remove-fmf-root - set to True to remove fmf root from
extracted sources
extracted sources
Selecting tests containing specified link is possible using 'link'
option accepting RELATION:TARGET format of values. Regular
Expand Down
3 changes: 2 additions & 1 deletion tmt/steps/prepare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
if TYPE_CHECKING:
import tmt.base
import tmt.cli
from tmt.base import Plan


@dataclasses.dataclass
Expand Down Expand Up @@ -117,7 +118,7 @@ class Prepare(tmt.steps.Step):
def __init__(
self,
*,
plan: 'tmt.base.Plan',
plan: 'Plan',
data: tmt.steps.RawStepDataArgument,
logger: tmt.log.Logger) -> None:
""" Initialize prepare step data """
Expand Down

0 comments on commit 8b81a3b

Please sign in to comment.