Skip to content
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ venv/
*.log
venv
venv37
.vscode/
.venv
10 changes: 10 additions & 0 deletions src/fixate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
__version__ = "0.5.7"

import fixate.sequencer
import fixate.config

# Create the global sequencer here so it can be imported and
# used elsewhere with better traceability/type-hints/auto-complete
global_sequencer = fixate.sequencer.Sequencer()
# Plan to deprecate calls to RESOURCES[] and gradual replace.
# Keep here now for backwards-compatibility with test_scripts
fixate.config.RESOURCES["SEQUENCER"] = global_sequencer
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been slowly trying to remove any object instantiation from happening at import time. Depending on how tangled things are, it might be a good change to do that here? The main entry point would create the Sequencer object and assign it to the global at startup. (this is probably something that should be deferred to a follow PR)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this could be a complete mess, because test scripts at the moment might rely on reference to the Sequencer at import time :(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted and moved to a separate branch. Nearly all our current test scripts fails the new atzip.pyz checks due to this, so will spend a bit more time cleaning it up there.

9 changes: 5 additions & 4 deletions src/fixate/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from zipimport import zipimporter
from pubsub import pub
import fixate.config
import fixate
from fixate.core.exceptions import SequenceAbort
from fixate.core.ui import user_serial, user_ok
from fixate.reporting import register_csv, unregister_csv
Expand Down Expand Up @@ -110,7 +111,7 @@
)


def load_test_suite(script_path, zip_path, zip_selector):
def load_test_suite(script_path: str, zip_path: str, zip_selector: str):
"""
Attempts to load a Fixate Script file from an absolute path.
Try loading from zip, then direct script otherwise
Expand Down Expand Up @@ -163,8 +164,7 @@ def __init__(self, test_script_path, args):
# General setup
self.test_script_path = test_script_path
self.args = args
self.sequencer = fixate.sequencer.Sequencer()
fixate.config.RESOURCES["SEQUENCER"] = self.sequencer
self.sequencer = fixate.global_sequencer

# Environment specific setup
# TODO remove this to plugin architecture
Expand Down Expand Up @@ -212,7 +212,7 @@ def run_fixate(self):


class FixateWorker:
def __init__(self, sequencer, test_script_path, args):
def __init__(self, sequencer: fixate.sequencer.Sequencer, test_script_path, args):
self.sequencer = sequencer
self.test_script_path = test_script_path
self.args = args
Expand Down Expand Up @@ -374,6 +374,7 @@ def run_main_program(test_script_path=None):

fixate.config.load_config(args.config)
fixate.config.load_dict_config({"log_file": args.log_file})
# Could this be replaced with a simple log_file variable in fixate.config ^ ?
Copy link
Copy Markdown
Collaborator

@jcollins1983 jcollins1983 Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question, I wouldn't mind talking to @clint-lawrence about the motivation for using the load_dict_config method. But, I don't think it's something that's pertinent to this PR. @clint-lawrence, do you think it would be worth enabling discussions so that things like this can be flagged there instead of random comments in code?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just create an issue?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had thought that, but I had a Wall-E spork moment, and didn't really think that it's an issue per se. But happy to stick with using issues.

supervisor = FixateSupervisor(test_script_path, args)
exit(supervisor.run_fixate())

Expand Down
Loading