def create_base_experiment( sacred_args, name=None): #path=Config.LOG_DIR, db_name=Config.DB_NAME): ex = Experiment(name) print(name) ex.capture(set_device) ex.main(main) ex.capture(run_train) ex.command(evaluate_experiment) ex.command(test_config) ex.command(show_options) ex.command(evaluate_checkpoint) # set default values ex = config_builder.build(ex) # set observers but check if maybe sacred will create them # on its own """ TODO Problem is that we create the experiment before the command line is parsed by sacred. But then we cannot set default values without using a shell script. Or modify the file path for the logger.""" if Config.LOG_DIR is not None and '-F' not in sacred_args: path = Config.LOG_DIR if name is not None: path = os.path.join(path, name) file_ob = FileStorageObserver.create(path) ex.observers.append(file_ob) if Config.SLACK_WEBHOOK_URL != "": slack_ob = SlackObserver(Config.SLACK_WEBHOOK_URL) ex.observers.append(slack_ob) if (Config.MONGO_DB_NAME is not None and Config.MONGO_DB_NAME != "") \ and '-m' not in sacred_args: if Config.MONGO_USER != "": mongo_ob = MongoObserver.create(username=Config.MONGO_USER, password=Config.MONGO_PW, url=Config.MONGO_URL, authMechanism="SCRAM-SHA-256", db_name=Config.MONGO_DB_NAME) else: mongo_ob = MongoObserver.create(url=Config.MONGO_URL, db_name=Config.MONGO_DB_NAME) ex.observers.append(mongo_ob) return ex