scarlehoff / pyHepGrid

Tool for distributed computing management geared towards HEP applications.
GNU General Public License v3.0
6 stars 4 forks source link

Import runcards from directory path #25

Closed marianheil closed 5 years ago

marianheil commented 5 years ago

it would be nice if we could import the runcard directly from a given path, independent of its location, i.e. both pyHepGrid man /some/path/to/a/runcard/runcard.py -B and cd /some/path/to/a/runcard && pyHepGrid man runcard.py -B should give the same result.

Currently only the latter works. The first version throws:

Traceback (most recent call last):
  File "/bin/pyHepGrid", line 11, in <module>
    load_entry_point('pyHepGrid', 'console_scripts', 'pyHepGrid')()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/pyHepGrid/src/pyHepGrid/main.py", line 5, in <module>
    from pyHepGrid.src.header import arctable, diractable, arcprodtable, slurmprodtable, \
  File "/pyHepGrid/src/pyHepGrid/src/header.py", line 94, in <module>
    runcard = importlib.import_module(runcard_file.replace(".py","").replace("/","."))
  File "/usr/lib64/python3.6/importlib/__init__.py", line 121, in import_module
    raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for '..................some.path.to.a.runcard.runcard'
scarlehoff commented 5 years ago

The correct way, of course, is to have config files or yml files we parse to read all values in a very sophisticated way.

Just to say I acknowledge there is a correct way, the PR #26 should fix it.