From e188ca4040ba59b7e61402a3d48c888463b3a4bd Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 13 Sep 2022 10:46:44 +0200 Subject: [PATCH] Debug entry point --- esds/__main__.py | 7 +++---- esds/platform.py | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/esds/__main__.py b/esds/__main__.py index bf05b24..4bb167d 100644 --- a/esds/__main__.py +++ b/esds/__main__.py @@ -1,8 +1,5 @@ import sys, argparse, os -import platform - -# Allow importlib to import file from current working directory -sys.path.insert(0, os.getcwd()) +from .platform import YAMLPlatformFile def run(arguments): parser = argparse.ArgumentParser(description='Run a simulation') @@ -10,6 +7,8 @@ def run(arguments): args = parser.parse_args(arguments[1:]) if args.platform: simulation=YAMLPlatformFile(args.platform) + # Allow importlib (in simulator.run()) to import file from the platform.yaml directory + sys.path.insert(0, simulation.location) simulation.run() else: parser.print_help() diff --git a/esds/platform.py b/esds/platform.py index 144e552..6742e9d 100644 --- a/esds/platform.py +++ b/esds/platform.py @@ -1,7 +1,7 @@ import yaml, os, importlib import numpy as np -import Simulator +from .simulator import Simulator class UnitsParser: def node_range(r,limit): @@ -46,6 +46,7 @@ class YAMLPlatformFile: def __init__(self, file_path): self.file_path=file_path + self.location=os.path.dirname(os.path.abspath(file_path)) self.default={ "breakpoints": [], "breakpoints_every": None, @@ -152,7 +153,7 @@ class YAMLPlatformFile: words=impl.split() r=UnitsParser.node_range(words[0],self.default["node_count"]) file="".join(words[1:]) - if not os.path.exists(file): + if not os.path.exists(os.path.join(self.location,file)): self.parsing_error("File "+file+ " not found") path, extension = os.path.splitext(file) if extension != ".py":