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

Merging in old changes #142

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3a09d1a
upgrading scannables
petered Jul 17, 2018
8fb2bd9
ok, the scan thing is internally messy but seems to work'
petered Jul 18, 2018
8688d22
fixed rsync-copying-all-experiments problem
petered Jul 19, 2018
a0a4a69
a bunch of things with nested structures
petered Aug 7, 2018
0db3d40
everything
petered Sep 14, 2018
ef24bb3
ok these are kind of working
petered Sep 22, 2018
e11bceb
stuuuuuf
petered Oct 19, 2018
e473ff1
aahhh
petered Oct 19, 2018
6232256
ARTEMIS CHANGES FROM DEAD MACHINE
Nov 12, 2018
949dcd4
ducks now support boolean indexing
Nov 20, 2018
e1700ca
stuuuufff
petered Dec 7, 2018
2e412dd
join and split
petered Dec 14, 2018
b745818
fixed pareto stuff
petered Dec 19, 2018
c1fa4b6
ooook
petered Dec 19, 2018
f4a2da6
before-changing-again
petered Dec 21, 2018
1339210
puuuush
petered Dec 21, 2018
0962503
added async dataloaders
petered Jan 2, 2019
ba84ebd
async updates
petered Jan 2, 2019
fd727b1
Merge branch 'peter' of http://github.com/QUVA-Lab/artemis into peter
petered Jan 3, 2019
455ebe4
rate limiter made
petered Jan 3, 2019
eb56b70
oook
petered Jan 3, 2019
64e7c26
profile improvements
petered Jan 4, 2019
0a70f5b
compatibility
petered Jan 5, 2019
8e9aa2f
ook
petered Jan 17, 2019
c97b756
oook
petered Jan 22, 2019
792bd8d
lilthings
petered Jan 24, 2019
34ae201
Merge branch 'peter' of http://github.com/QUVA-Lab/artemis into peter
petered Jan 24, 2019
13ba79f
windowsfix
Jan 28, 2019
4db0048
parameter_search improvements
petered Feb 14, 2019
fd82c62
stuuuff
petered Feb 16, 2019
50c6c44
preclean
petered Feb 16, 2019
4bf2fe0
cleaned up parallel coords plot
petered Feb 17, 2019
c46b2fd
indice build
petered Apr 11, 2019
7003281
addressed test fail
petered Apr 16, 2019
6c3e214
fixed
petered Apr 16, 2019
c8ba0d8
addressed errors
petered Apr 16, 2019
8d0123e
again
petered Apr 16, 2019
114c546
should pass?
petered Apr 16, 2019
11c0a1b
address tests
petered Apr 17, 2019
3180e45
Merge pull request #1 from petered/peter
petered Apr 17, 2019
f1635f3
oops forgot to push cleanup
petered Apr 17, 2019
b98f38b
more clean
petered Apr 17, 2019
ad2871f
Merge pull request #2 from petered/peter
petered Apr 17, 2019
ba685eb
added a bunch of typing and allowed experiment selection by user range
petered Sep 15, 2022
d2bd393
Update README.md
petered Jan 8, 2023
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ venv/
# Files
/Data
/docs/build

.pytest_cache
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ For more examples of how to use artemis, read the [Artemis Documentation](http:/
To use artemis from within your project, use the following to install Artemis and its dependencies: (You probably want to do this in a virtualenv with the latest version of pip - run `virtualenv venv; source venv/bin/activate; pip install --upgrade pip;` to make one and enter it).


**Option 1: Simple install:**
**Option 1: Simple install (stable) :**

```
pip install artemis-ml
```

**Option 2: Install as source.**
**Option 2: Install as source (master branch, do this if you want latest updates or you want to contribute to Artemis).**

```
pip install -e git+http://github.com/QUVA-Lab/artemis.git#egg=artemis
pip install -e git+https://github.com/petered/artemis.git#egg=artemis-ml
```
This will install it in `(virtual env or system python root)/src/artemis`. You can edit the code and submit pull requests to our git repo. To install with the optional [remote plotting](https://github.com/QUVA-Lab/artemis/blob/master/artemis/remote/README.md) mode enabled, add the `[remote_plotting]` option, as in: `pip install -e git+http://github.com/QUVA-Lab/artemis.git#egg=artemis[remote_plotting]`

Expand Down
19 changes: 14 additions & 5 deletions artemis/experiments/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ExperimentFunction(object):
This is the most general decorator. You can use this to add details on the experiment.
"""

def __init__(self, show = show_record, compare = compare_experiment_records, display_function=None, comparison_function=None, one_liner_function=sensible_str, is_root=False):
def __init__(self, show = None, compare = compare_experiment_records, display_function=None, comparison_function=None, one_liner_function=None, result_parser = None, is_root=False, name=None):
"""
:param show: A function that is called when you "show" an experiment record in the UI. It takes an experiment
record as an argument.
Expand All @@ -55,16 +55,17 @@ def __init__(self, show = show_record, compare = compare_experiment_records, dis
You can use call this via the UI with the compare_experiment_results command.
:param one_liner_function: A function that takes your results and returns a 1 line string summarizing them.
:param is_root: True to make this a root experiment - so that it is not listed to be run itself.
:param name: Custom name (if None, experiment will be named after decorated function)
"""
self.show = show
self.compare = compare

if display_function is not None:
assert show is show_record, "You can't set both display function and show. (display_function is deprecated)"
assert show is None, "You can't set both display function and show. (display_function is deprecated)"
show = lambda rec: display_function(rec.get_result())

if comparison_function is not None:
assert compare is compare_experiment_records, "You can't set both display function and show. (display_function is deprecated)"
assert compare is None, "You can't set both display function and show. (display_function is deprecated)"

def compare(records):
record_experiment_ids_uniquified = uniquify_duplicates(rec.get_experiment_id() for rec in records)
Expand All @@ -74,15 +75,23 @@ def compare(records):
self.compare = compare
self.is_root = is_root
self.one_liner_function = one_liner_function
self.result_parser = result_parser
self.name = name

def __call__(self, f):
"""
:param Callable f: The function you decorated
:return Experiment: An Experiment object (It still behaves as the original function when you call it, but now
has additional methods attached to it associated with the experiment).
"""
f.is_base_experiment = True
ex = Experiment(
name=f.__name__,
name=f.__name__ if self.name is None else self.name,
function=f,
show=self.show,
compare = self.compare,
one_liner_function=self.one_liner_function,
is_root=self.is_root
is_root=self.is_root,
result_parser=self.result_parser,
)
return ex
194 changes: 118 additions & 76 deletions artemis/experiments/experiment_management.py

Large diffs are not rendered by default.

38 changes: 31 additions & 7 deletions artemis/experiments/experiment_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from contextlib import contextmanager
from getpass import getuser
from pickle import PicklingError
import itertools

from datetime import datetime, timedelta
from uuid import getnode
Expand All @@ -23,7 +24,7 @@
from artemis.general.display import CaptureStdOut
from artemis.general.functional import get_partial_chain, get_defined_and_undefined_args
from artemis.general.hashing import compute_fixed_hash
from artemis.general.should_be_builtins import nested
from artemis.general.should_be_builtins import nested, natural_keys
from artemis.general.test_mode import is_test_mode
from artemis.general.test_mode import set_test_mode
from artemis._version import __version__ as ARTEMIS_VERSION
Expand Down Expand Up @@ -240,6 +241,7 @@ def get_figure_locs(self, include_directory=True):
:return: A list of string file paths.
"""
locs = [f for f in os.listdir(self._experiment_directory) if f.startswith('fig-')]
locs = sorted(locs, key=natural_keys)
if include_directory:
return [os.path.join(self._experiment_directory, f) for f in locs]
else:
Expand Down Expand Up @@ -289,7 +291,7 @@ def get_experiment(self):
"""
Load the experiment associated with this record.
Note that this will raise an ExperimentNotFoundError if the experiment has not been imported.
:return: An Experiment object
:return Experiment: An Experiment object
"""
from artemis.experiments.experiments import load_experiment
return load_experiment(self.get_experiment_id())
Expand All @@ -310,7 +312,10 @@ def get_runtime(self):
"""
:return datetime.timedelta: A timedelta object
"""
return timedelta(seconds=self.info.get_field(ExpInfoFields.RUNTIME))
try:
return timedelta(seconds=self.info.get_field(ExpInfoFields.RUNTIME))
except KeyError: # Which will happen if the experiment is still running or was killed without due process
return None

def get_dir(self):
"""
Expand Down Expand Up @@ -506,6 +511,7 @@ def get_current_record_id():
def get_current_record_dir(default_if_none = True):
"""
The directory in which the results of the current experiment are recorded.
:param default_if_none: True to put records in the "default" dir if no experiment is running.
"""
if _CURRENT_EXPERIMENT_RECORD is None and default_if_none:
return get_artemis_data_path('experiments/default/', make_local_dir=True)
Expand Down Expand Up @@ -657,7 +663,19 @@ def clear_experiment_records(ids):
ExperimentRecord(exp_path).delete()


def save_figure_in_record(name, fig=None, default_ext='.pkl'):
_figure_ixs = {}


def _get_next_figure_name(name_pattern, directory):
start_ix = _figure_ixs[directory] if directory in _figure_ixs else 0
for ix in itertools.count(start_ix):
full_path = os.path.join(directory, name_pattern).format(ix)
if not os.path.exists(full_path):
_figure_ixs[directory] = ix+1
return full_path


def save_figure_in_record(name=None, fig=None, default_ext='.pkl'):
'''
Saves the given figure in the experiment directory. If no figure is passed, plt.gcf() is saved instead.
:param name: The name of the figure to be saved
Expand All @@ -667,11 +685,17 @@ def save_figure_in_record(name, fig=None, default_ext='.pkl'):
'''
import matplotlib.pyplot as plt
from artemis.plotting.saving_plots import save_figure

if fig is None:
fig = plt.gcf()
save_path = os.path.join(get_current_record_dir(), name)
save_figure(fig, path=save_path, default_ext=default_ext)
return save_path

current_dir = get_current_record_dir()
if name is None:
path = _get_next_figure_name(name_pattern='fig-{}.pkl', directory=current_dir)
else:
path = os.path.join(current_dir, name)
save_figure(fig, path=path, default_ext=default_ext)
return path


def get_serialized_args(argdict):
Expand Down
Loading