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

Fix ConfigSpace dependency issue #955

Merged
merged 7 commits into from
Jul 4, 2022
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
40 changes: 2 additions & 38 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=abstract-class-instantiated,useless-super-delegation,no-member,keyword-arg-before-vararg,unidiomatic-typecheck,redefined-outer-name,fixme,F0401,intern-builtin,wrong-import-position,wrong-import-order,no-self-use,
C0415, F0010, R0205, R1705, R1711, R1720, W0106, W0107, W0127, W0706, C0330, C0326, W1203, E1136
disable=abstract-class-instantiated,useless-super-delegation,no-member,keyword-arg-before-vararg,unidiomatic-typecheck,redefined-outer-name,fixme,F0401,wrong-import-position,wrong-import-order,
C0415, F0010, R0205, R1705, R1711, R1720, W0106, W0107, W0127, W0706, W1203, E1136

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -128,12 +128,6 @@ max-line-length=100
# Maximum number of lines in a module
max-module-lines=750

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
Expand Down Expand Up @@ -215,46 +209,28 @@ notes=FIXME,XXX,TODO

[BASIC]

# Naming hint for argument names
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct argument names
argument-rgx=^(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Naming hint for attribute names
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct attribute names
attr-rgx=^(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata,lalala,alalal

# Naming hint for class attribute names
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Regular expression matching correct class attribute names
class-attribute-rgx=^([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$

# Naming hint for class names
class-name-hint=[A-Z_][a-zA-Z0-9]+$

# Regular expression matching correct class names
class-rgx=^[A-Z_][a-zA-Z0-9]+$

# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$

# Regular expression matching correct constant names
const-rgx=^(([A-Z_][A-Z0-9_]*)|(__.*__)|([a-z][a-z0-9_]{1,30})|(_[a-z0-9_]*))$

# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1

# Naming hint for function names
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct function names
function-rgx=^(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

Expand All @@ -264,21 +240,12 @@ good-names=i,j,k,v,ex,Run,_,f,e
# Include a hint for the correct naming format with invalid-name
include-naming-hint=no

# Naming hint for inline iteration names
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$

# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$

# Naming hint for method names
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Regular expression matching correct method names
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Naming hint for module names
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

# Regular expression matching correct module names
module-rgx=^(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

Expand All @@ -294,9 +261,6 @@ no-docstring-rgx=^_
# to this list to register other decorators that produce valid properties.
property-classes=abc.abstractproperty

# Naming hint for variable names
variable-name-hint=(([a-z][a-z0-9_]{1,30})|(_[a-z0-9_]*))$

# Regular expression matching correct variable names
variable-rgx=^(([a-z][a-z0-9_]{1,30})|(_[a-z0-9_]*))$

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
],
"dehb": [
"ConfigSpace",
"dehb @ git+https://github.com/automl/DEHB.git@development#egg=dehb",
"dehb @ git+https://github.com/bouthilx/DEHB.git@master#egg=dehb",
"sspace @ git+https://github.com/Epistimio/sample-space.git@master#egg=sspace",
],
"bohb": [
Expand Down
2 changes: 1 addition & 1 deletion src/orion/analysis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def average(trials, group_by="order", key="best", return_var=False):
return trials

group = trials.groupby(group_by)
means = list()
means = []
keys = [v.strip() for v in key.split(",")]
for k in keys:
mean = group[k].mean().reset_index().rename(columns={k: f"{k}_mean"})
Expand Down
2 changes: 1 addition & 1 deletion src/orion/analysis/partial_dependency_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def partial_dependency(
]
data = pandas.DataFrame(data, columns=flattened_space.keys())

partial_dependencies = dict()
partial_dependencies = {}
for x_i, x_name in enumerate(params):
grid, averages, stds = partial_dependency_grid(
flattened_space, model, [x_name], data, n_grid_points
Expand Down
1 change: 1 addition & 0 deletions src/orion/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
import logging

# pylint: disable=consider-using-from-import
import orion.core.io.experiment_builder as experiment_builder
from orion.client.cli import (
interrupt_trial,
Expand Down
2 changes: 1 addition & 1 deletion src/orion/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def report_results(data):
if _HAS_REPORTED_RESULTS:
raise RuntimeWarning("Has already reported evaluation results once.")
if IS_ORION_ON:
with open(RESULTS_FILENAME, "w") as results_file:
with open(RESULTS_FILENAME, "w", encoding="utf8") as results_file:
json.dump(data, results_file)
else:
print(data)
Expand Down
51 changes: 19 additions & 32 deletions src/orion/client/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from contextlib import contextmanager

import orion.core
import orion.core.utils.format_trials as format_trials
from orion.client.runner import Runner
from orion.core.io.database import DuplicateKeyError
from orion.core.utils.exceptions import (
Expand All @@ -21,6 +20,7 @@
UnsupportedOperation,
WaitingForTrials,
)
from orion.core.utils.format_trials import dict_to_trial
from orion.core.utils.working_dir import SetupWorkingDir
from orion.core.worker.producer import Producer
from orion.core.worker.trial import AlreadyReleased, Trial, TrialCM
Expand Down Expand Up @@ -374,15 +374,14 @@ def insert(self, params, results=None, reserve=False):
"Cannot observe a trial and reserve it. A trial with results has status "
"`completed` and cannot be reserved."
)
trial = format_trials.dict_to_trial(params, self.space)
trial = dict_to_trial(params, self.space)
try:
self._experiment.register_trial(trial, status="reserved")
self._maintain_reservation(trial)
except DuplicateKeyError as e:
message = (
"A trial with params {} already exist for experiment {}-v{}".format(
params, self.name, self.version
)
f"A trial with params {params} already exist for experiment "
f"{self.name}-v{self.version}"
)
raise DuplicateKeyError(message) from e

Expand Down Expand Up @@ -439,18 +438,16 @@ def reserve(self, trial):
return
elif trial.status == "reserved" and trial.id not in self._pacemakers:
raise RuntimeError(
"Trial {} is already reserved by another process.".format(trial.id)
f"Trial {trial.id} is already reserved by another process."
)
try:
self._experiment.set_trial_status(
trial, "reserved", heartbeat=self.heartbeat
)
except FailedUpdate as e:
if self.get_trial(trial) is None:
raise ValueError(
"Trial {} does not exist in database.".format(trial.id)
) from e
raise RuntimeError("Could not reserve trial {}.".format(trial.id)) from e
raise ValueError(f"Trial {trial.id} does not exist in database.") from e
raise RuntimeError(f"Could not reserve trial {trial.id}.") from e

self._maintain_reservation(trial)

Expand Down Expand Up @@ -490,19 +487,15 @@ def release(self, trial, status="interrupted"):
self._producer.observe(trial)
except FailedUpdate as e:
if self.get_trial(trial) is None:
raise ValueError(
"Trial {} does not exist in database.".format(trial.id)
) from e
raise ValueError(f"Trial {trial.id} does not exist in database.") from e
if current_status != "reserved":
raise_if_unreserved = False
raise AlreadyReleased(
"Trial {} was already released locally.".format(trial.id)
f"Trial {trial.id} was already released locally."
) from e

raise RuntimeError(
"Reservation for trial {} has been lost before release.".format(
trial.id
)
f"Reservation for trial {trial.id} has been lost before release."
) from e
finally:
self._release_reservation(trial, raise_if_unreserved=raise_if_unreserved)
Expand Down Expand Up @@ -625,12 +618,10 @@ def observe(self, trial, results):
except FailedUpdate as e:
if self.get_trial(trial) is None:
raise_if_unreserved = False
raise ValueError(
"Trial {} does not exist in database.".format(trial.id)
) from e
raise ValueError(f"Trial {trial.id} does not exist in database.") from e

raise RuntimeError(
"Reservation for trial {} has been lost.".format(trial.id)
f"Reservation for trial {trial.id} has been lost."
) from e
finally:
self._release_reservation(trial, raise_if_unreserved=raise_if_unreserved)
Expand Down Expand Up @@ -826,9 +817,9 @@ def close(self):

if self._pacemakers:
raise RuntimeError(
"There is still reserved trials: {}\nRelease all trials before "
"closing the client, using "
"client.release(trial).".format(self._pacemakers.keys())
f"There is still reserved trials: {self._pacemakers.keys()}\n"
"Release all trials before closing the client, using "
"client.release(trial)."
)

###
Expand All @@ -845,19 +836,17 @@ def _free_executor(self):

def __repr__(self):
"""Represent the object as a string."""
return "Experiment(name=%s, version=%s)" % (self.name, self.version)
return f"Experiment(name={self.name}, version={self.version})"

def _verify_reservation(self, trial):
if trial.id not in self._pacemakers:
raise RuntimeError(
"Trial {} had no pacemakers. Was it reserved properly?".format(trial.id)
f"Trial {trial.id} had no pacemakers. Was it reserved properly?"
)

if self.get_trial(trial).status != "reserved":
self._release_reservation(trial)
raise RuntimeError(
"Reservation for trial {} has been lost.".format(trial.id)
)
raise RuntimeError(f"Reservation for trial {trial.id} has been lost.")

def _maintain_reservation(self, trial):
self._pacemakers[trial.id] = TrialPacemaker(trial)
Expand All @@ -867,9 +856,7 @@ def _release_reservation(self, trial, raise_if_unreserved=True):
if trial.id not in self._pacemakers:
if raise_if_unreserved:
raise RuntimeError(
"Trial {} had no pacemakers. Was it reserved properly?".format(
trial.id
)
f"Trial {trial.id} had no pacemakers. Was it reserved properly?"
)
else:
return
Expand Down
6 changes: 3 additions & 3 deletions src/orion/client/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Protected(object):

def __init__(self):
self.signal_received = None
self.handlers = dict()
self.handlers = {}
self.start = 0
self.delayed = 0
self.signal_installed = False
Expand Down Expand Up @@ -172,7 +172,7 @@ def __init__(
self.worker_broken_trials = 0
self.trials = 0
self.futures = []
self.pending_trials = dict()
self.pending_trials = {}
self.stat = _Stat()
self.n_worker_override = n_workers

Expand Down Expand Up @@ -405,7 +405,7 @@ def _release_all(self):
except AlreadyReleased:
pass

self.pending_trials = dict()
self.pending_trials = {}

def _suggest_trials(self, count):
"""Suggest a bunch of trials to be dispatched to the workers"""
Expand Down
2 changes: 1 addition & 1 deletion src/orion/core/cli/db/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import sys

import orion.core.io.experiment_builder as experiment_builder
from orion.core.io import experiment_builder
from orion.core.utils.pptree import print_tree
from orion.core.utils.terminal import confirm_name
from orion.storage.base import get_storage
Expand Down
2 changes: 1 addition & 1 deletion src/orion/core/cli/db/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import sys

import orion.core.io.experiment_builder as experiment_builder
from orion.core.io import experiment_builder
from orion.core.utils.pptree import print_tree
from orion.core.utils.terminal import confirm_name
from orion.storage.base import get_storage
Expand Down
1 change: 1 addition & 0 deletions src/orion/core/cli/db/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import logging
import sys

# pylint:disable=consider-using-from-import
import orion.core.io.experiment_builder as experiment_builder
from orion.core.utils.pptree import print_tree
from orion.core.utils.terminal import confirm_name
Expand Down
8 changes: 3 additions & 5 deletions src/orion/core/cli/db/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def main(*args):
cancel = ""
while cancel.strip().lower() not in ["y", "n"]:
cancel = ask_question(
"This will overwrite {}, do you want to proceed? (y/n) ".format(
default_file
),
f"This will overwrite {default_file}, do you want to proceed? (y/n) ",
"n",
)

Expand All @@ -67,7 +65,7 @@ def main(*args):
arg_vals = {}
for arg_name, default_value in sorted(db_args.items()):
arg_vals[arg_name] = ask_question(
"Enter the database {}: ".format(arg_name), default_value
f"Enter the database {arg_name}: ", default_value
)

config = {"database": {"type": _type, **arg_vals}}
Expand All @@ -78,5 +76,5 @@ def main(*args):
dirs = "/".join(default_file.split("/")[:-1])
os.makedirs(dirs, exist_ok=True)

with open(default_file, "w") as output:
with open(default_file, "w", encoding="utf8") as output:
yaml.dump(config, output, default_flow_style=False)
6 changes: 3 additions & 3 deletions src/orion/core/cli/db/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
import sys

import orion.core.io.experiment_builder as experiment_builder
from orion.core.io import experiment_builder
from orion.core.io.database.ephemeraldb import EphemeralCollection
from orion.core.io.database.mongodb import MongoDB
from orion.core.io.database.pickleddb import PickledDB
Expand Down Expand Up @@ -40,7 +40,7 @@ def ask_question(question, default=None):

"""
if default is not None:
question = question + " (default: {}) ".format(default)
question = f"{question} (default: {default}) "

answer = input(question)

Expand Down Expand Up @@ -182,7 +182,7 @@ def upgrade_state(self, state):
if state["_indexes"] and isinstance(
next(iter(state["_indexes"].keys())), tuple
):
self._indexes = dict()
self._indexes = {}
for keys, values in state["_indexes"].items():
if isinstance(keys, str):
self._indexes[keys] = values
Expand Down
Loading