Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use user_script_config from parser in EVC #655

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/orion/core/evc/conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,16 +1311,18 @@ class CommandLineConflict(Conflict):

# pylint: disable=unused-argument
@classmethod
def get_nameless_args(
cls, config, user_script_config=None, non_monitored_arguments=None, **kwargs
):
def get_nameless_args(cls, config, non_monitored_arguments=None, **kwargs):
"""Get user's commandline arguments which are not dimension definitions"""
# Used python API
if "parser" not in config["metadata"]:
return ""

if user_script_config is None:
user_script_config = (
config.get("metadata", {}).get("parser", {}).get("config_prefix")
)
if not user_script_config:
user_script_config = orion.core.config.worker.user_script_config

if non_monitored_arguments is None:
non_monitored_arguments = orion.core.config.evc.non_monitored_arguments

Expand Down Expand Up @@ -1478,15 +1480,20 @@ class ScriptConfigConflict(Conflict):

# pylint:disable=unused-argument
@classmethod
def get_nameless_config(cls, config, user_script_config=None, **branching_kwargs):
def get_nameless_config(cls, config, **branching_kwargs):
"""Get configuration dict of user's script without dimension definitions"""
# Used python API
if "parser" not in config["metadata"]:
return ""

if user_script_config is None:
user_script_config = (
config.get("metadata", {}).get("parser", {}).get("config_prefix")
)
if not user_script_config:
user_script_config = orion.core.config.worker.user_script_config

log.debug("User script config: %s", user_script_config)

parser = OrionCmdlineParser(user_script_config, allow_non_existing_files=True)
parser.set_state_dict(config["metadata"]["parser"])

Expand Down
29 changes: 19 additions & 10 deletions tests/functional/branching/test_branching.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
"""Perform a functional test for branching."""

import logging
import os

import pytest
Expand Down Expand Up @@ -391,7 +392,7 @@ def init_full_x_ignore_cli(init_full_x):


@pytest.fixture
def init_full_x_new_config(init_full_x, tmp_path):
def init_full_x_new_config(init_full_x, tmp_path, caplog):
"""Add configuration script"""
name = "full_x"
branch = "full_x_new_config"
Expand All @@ -403,16 +404,24 @@ def init_full_x_new_config(init_full_x, tmp_path):
)
)

orion.core.cli.main(
(
"hunt --enable-evc --init-only -n {branch} --branch-from {name} "
"--cli-change-type noeffect "
"--config-change-type unsure "
"./black_box_new.py -x~uniform(-10,10) --config {config_file}"
caplog.clear()
with caplog.at_level(logging.DEBUG):
orion.core.cli.main(
(
"hunt --enable-evc --init-only -n {branch} --branch-from {name} "
"--cli-change-type noeffect "
"--config-change-type unsure "
"--user-script-config custom-config "
"./black_box_new.py -x~uniform(-10,10) --custom-config {config_file}"
)
.format(name=name, branch=branch, config_file=config_file)
.split(" ")
)
.format(name=name, branch=branch, config_file=config_file)
.split(" ")
)
# For parent experiment
assert "User script config: config" in caplog.text
# For child experiment
assert "User script config: custom-config" in caplog.text

orion.core.cli.main(
"insert -n {branch} script -x=1.2 -y=2".format(branch=branch).split(" ")
)
Expand Down