Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/stil_ignore…
Browse files Browse the repository at this point in the history
…_incl
  • Loading branch information
rlaj committed Oct 4, 2024
2 parents 37a96af + 4f8ae75 commit 01c28d4
Show file tree
Hide file tree
Showing 27 changed files with 842 additions and 588 deletions.
818 changes: 393 additions & 425 deletions .github/workflows/publish.yml

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions .github/workflows/regression_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ jobs:
- name: Setup No-App Env
uses: Wandalen/[email protected]
with:
attempt_limit: 2
attempt_limit: 3
attempt_delay: 10000 # ms = 10 seconds
current_path: test_apps/python_no_app
command: poetry install

Expand Down Expand Up @@ -317,8 +318,12 @@ jobs:
# Issue being that working on a newer Python version than what's released will not resolve
# Workaround by removing origen_metal package from origen dependencies and installing separately
- name: Hack origen pyproject
working-directory: python/origen
run: poetry remove origen_metal
uses: Wandalen/[email protected]
with:
attempt_limit: 3
attempt_delay: 10000 # ms = 10 seconds
current_path: python/origen
command: poetry remove origen_metal

- name: Install Origen Packages
run: |
Expand Down
2 changes: 2 additions & 0 deletions python/origen/origen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def __getattr__(name: str):
return origen._plugins
else:
return _plugins
elif name == "output_directory" or name == "output_dir":
return _origen.output_directory()
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

# Replace origen_metal's native _origen_metal built library
Expand Down
10 changes: 9 additions & 1 deletion python/origen/origen/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def commands_dir(self):
return None

@property
def session(self):
def app_session(self):
''' Return this app's session store'''
return origen.sessions.app_session(self)

Expand All @@ -103,6 +103,14 @@ def user_session(self):
''' Return this app's user session store'''
return origen.sessions.user_session(self)

@property
def session(self):
''' If in an application workspace, return the this app's app session, otherwise this app's user session'''
if origen.app:
return self.app_session
else:
return self.user_session

@property
def rc(self):
return origen_metal.frontend.frontend().revision_control
Expand Down
46 changes: 32 additions & 14 deletions python/origen/origen/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def run_cmd(command,
--------
* :link-to:`Example Application Commands <src_code:example_commands>`
'''

import origen
import _origen
import origen_metal
Expand All @@ -47,13 +46,13 @@ def run_cmd(command,
arg_indices = {}

if command == dispatch_plugin_cmd:
cmd_src = "plugin"
cmd_src = _origen.current_command.SourceType.Plugin
elif command == dispatch_aux_cmd:
cmd_src = "aux_ns"
cmd_src = _origen.current_command.SourceType.Aux
elif command == dispatch_app_cmd:
cmd_src = "app"
cmd_src = _origen.current_command.SourceType.App
else:
cmd_src = "core"
cmd_src = _origen.current_command.SourceType.Core
dispatch = {}

def wrap_mod_from_file(path):
Expand All @@ -62,7 +61,7 @@ def wrap_mod_from_file(path):
except Exception as e:
return [path, e]

def mod_from_modulized_path(root, sub_parts):
def find_mod(root, sub_parts):
root = pathlib.Path(root)
if not root.exists():
return [f"Root directory '{root}' does not exists or is not accessible"]
Expand All @@ -76,23 +75,30 @@ def mod_from_modulized_path(root, sub_parts):
if modulized_path.exists():
path = pathlib.Path(f"{modulized_path}/{'.'.join(sub_parts[(i+1):])}.py")
if path.exists():
return wrap_mod_from_file(path)
return path
else:
paths.append(path)
else:
return [f"From root '{root}', searched:", *[p.relative_to(root) for p in paths]]
return [f"From root '{root}', searched:", *[p.relative_to(root) for p in paths]]
else:
return [f"From root '{root}', searched:", *[p.relative_to(root) for p in paths]]
return wrap_mod_from_file(path)
return path

def mod_from_modulized_path(root, sub_parts):
m = find_mod(root, sub_parts)
if isinstance(m, list):
return m
return wrap_mod_from_file(m)

def call_user_cmd(cmd_type):
m = mod_from_modulized_path(dispatch_root, subcmds)

if isinstance(m, list):
if isinstance(m[1], Exception):
origen.log.error(f"Could not load {cmd_type} command implementation from '{('.').join(subcmds)}' ({m[0]})")
origen.log.error(f"Received exception:\n{m[1]}")
import traceback
origen.log.error(f"Received exception:\n{''.join(traceback.format_exception(m[1]))}")
else:
origen.log.error(f"Could not find implementation for {cmd_type} command '{('.').join(subcmds)}'")
for msg in m:
Expand Down Expand Up @@ -182,13 +188,13 @@ def run(func):

for ext in extensions:
current_ext = ext
if cmd_src == "core":
if cmd_src.is_core_cmd:
_dispatch_src = [command]
elif cmd_src == "app":
elif cmd_src.is_app_cmd:
_dispatch_src = []
else:
_dispatch_src = [dispatch_src]
m = mod_from_modulized_path(ext['root'], [cmd_src, *_dispatch_src, *subcmds])
m = mod_from_modulized_path(ext['root'], [cmd_src.root_name, *_dispatch_src, *subcmds])
if isinstance(m, list):
if len(m) == 2 and isinstance(m[1], Exception):
origen.log.error(f"Could not load {ext['source']} extension implementation from '{ext['name']}' ({m[0]})")
Expand All @@ -208,7 +214,20 @@ def run(func):
if "on_load" in ext:
getattr((ext["mod"]), ext["on_load"])(ext["mod"])
current_ext = None
_origen.current_command.set_command(command, subcmds, args, ext_args, arg_indices, ext_arg_indices, extensions)
if cmd_src.is_core_cmd:
_origen.current_command.set_command(command, subcmds, args, ext_args, arg_indices, ext_arg_indices, extensions, cmd_src, None, None)
else:
path = find_mod(dispatch_root, subcmds)
if isinstance(path, list):
if isinstance(path[1], Exception):
origen.log.error(f"Could not load {cmd_src} command implementation from '{('.').join(subcmds)}' ({path[0]})")
origen.log.error(f"Received exception:\n{path[1]}")
else:
origen.log.error(f"Could not find implementation for {cmd_src} command '{('.').join(subcmds)}'")
for msg in path:
origen.log.error(f" {msg}")
exit_proc(1)
_origen.current_command.set_command(command, subcmds, args, ext_args, arg_indices, ext_arg_indices, extensions, cmd_src, path, dispatch_src)

def run_ext(phase, continue_on_fail=False):
for ext in extensions:
Expand Down Expand Up @@ -416,7 +435,6 @@ def tabify(message):
print("Error")
print(tabify(repr(e)))


elif command == dispatch_app_cmd:
call_user_cmd("app")

Expand Down
6 changes: 5 additions & 1 deletion python/origen/origen/core/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def from_origen_cli(plugins):
origen._plugins = pls
return origen._plugins

class Plugin:
pass

class Plugins(UserDict):
def __init__(self):
UserDict.__init__(self)
Expand All @@ -33,7 +36,8 @@ def names(self):

def register(self, name):
a = importlib.import_module(f'{name}.application')
app = a.Application(root=Path(os.path.abspath(
a_pl = type("Application", (Plugin, a.Application), {})
app = a_pl(root=Path(os.path.abspath(
a.__file__)).parent.parent,
name=name)
self.data[name] = app
Expand Down
2 changes: 1 addition & 1 deletion python/origen/origen/utility/github.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import _origen

dispatch_workflow = _origen.utility.dispatch_workflow
dispatch_workflow = _origen.utility.revision_control.github.dispatch_workflow
104 changes: 38 additions & 66 deletions python/origen_metal/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions python/origen_metal/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ dependencies = [
]

[tool.poetry.dev-dependencies]
pytest = "^6.2.4"
pytest = "^7"
pytest-rerunfailures = "13.0" # Last version that supports Python 3.7
pdoc = "^7"
maturin = "1.7.0"

Expand All @@ -45,10 +46,9 @@ markers = [
"ldap: marks tests requiring/using the external ldap",
]

# SMcG - Commented out, breaks regression (setting up test/python_app env)
#[tool.poetry.build]
#script = "poetry_build.py"
#generate-setup-file = false
[tool.poetry.build]
script = "poetry_build.py"
generate-setup-file = false

[tool.maturin]
module-name = "origen_metal._origen_metal"
Expand Down
Loading

0 comments on commit 01c28d4

Please sign in to comment.