Hi, I just started using guild and I’m trying to integrate it with an existing project.
I have the following directory structure:
project/
├─ configs/
│ ├─ __init__.py
│ ├─ cfg1.py
│ ├─ cfg2.py
├─ utils/
│ ├─ base_config.py
Where the config files contain something similar to
from utils.base_config import BaseConfig
class Config(BaseConfig):
class Model:
architecture: MLP
class Parameters:
pass
if __name__ == "__main__":
Config.init()
train.main()
and BaseConfig.py
among other things does this
import __main__
class BaseConfig:
@classmethod
def init(cls):
with Path('configs/__init__.py').open('w+') as f:
f.writelines([f'from .{Path(str(__main__)).stem } import Config'])
f.flush()
Now, when I run guild run configs/cfg1.py
I get the following error:
Traceback (most recent call last):
File "C:\Users\username\PycharmProjects\project\configs\cfg1.py", line 56, in <module>
Config.init()
File "C:\Users\username\PycharmProjects\project\utils\base_config.py", line 13, in init
with Path('configs/__init__.py').open('w+') as f:
File "C:\Users\username\.conda\envs\project_env\lib\pathlib.py", line 1252, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "C:\Users\username\.conda\envs\project_env\lib\pathlib.py", line 1120, in _opener
return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'configs\\__init__.py'
Then, when I look into the sourcecode
directory of the run I see that only __init__.py
, cfg1.py
and cfg2.py
are present and the directory structure is not preserved (i.e. the three files are not under configs
). Any idea on how to solve this?
Also, I was wondering how I could log the configuration file. I tried playing with flag-dest:config
but couldn’t manage to make it work.