so I've been poking around with sacred a little bit and it seems great. unfortunately I did not find any multiple files use-cases examples like I am trying to implement.
so i have this file called configuration.py, it is intended to contain different variables which will (using sacred) be plugged in to the rest of the code (laying in different files):
from sacred import Experiment
ex = Experiment('Analysis')
@ex.config
def configure_analysis_default():
"""Initializes default """
generic_name = "C:\\basic_config.cfg" # configuration filename
message = "This is my generic name: %s!" % generic_name
print(message)
@ex.automain #automain function needs to be at the end of the file. Otherwise everything below it is not defined yet
# when the experiment is run.
def my_main(message):
print(message)
This by itself works great. sacred is working as expected. However, when I'm trying to introduce a second file named Analysis.py:
import configuration
from sacred import Experiment
ex = Experiment('Analysis')
@ex.capture
def what_is_love(generic_name):
message = " I don't know"
print(message)
print(generic_name)
@ex.automain
def my_main1():
what_is_love()
running Analysis.py yields:
Error:
TypeError: what_is_love is missing value(s) for ['generic_name']
I expected that the 'import configuration' statement to include the configuration.py file, thus importing everything that was configured in there including configure_analysis_default() alongside its decorator @ex.config and then inject it to what_is_love(generic_name). What am I doing wrong? how can i fix this?
Appreciate it!