Skip to content

Commit

Permalink
Merge 3c29dcc into 2b1e756
Browse files Browse the repository at this point in the history
  • Loading branch information
JarnoRFB committed Aug 8, 2019
2 parents 2b1e756 + 3c29dcc commit f90d1f6
Show file tree
Hide file tree
Showing 108 changed files with 4,819 additions and 3,688 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: master
hooks:
- id: black
language_version: python3.6
11 changes: 8 additions & 3 deletions CONTRIBUTING.rst
Expand Up @@ -66,22 +66,27 @@ local development.

$ git checkout -b name-of-your-bugfix-or-feature

4. Create your development environment and install the pre-commit hooks
$ # Activate your environment
$ pip install -r dev-requirements.txt
$ pre-commit install

Now you can make your changes locally.

4. When you're done making changes, check that your changes pass style and unit
5. When you're done making changes, check that your changes pass style and unit
tests, including testing other Python versions with tox::

$ tox

To get tox, just pip install it.

5. Commit your changes and push your branch to GitHub::
6. Commit your changes and push your branch to GitHub::

$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

6. Submit a pull request through the GitHub website.
7. Submit a pull request through the GitHub website.

.. _Fork: https://github.com/IDSIA/sacred/fork

Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Expand Up @@ -63,6 +63,10 @@ jobs:
IMAGE_NAME: 'ubuntu-16.04'
PYTHON_VERSION: '3.7'
TOX_CMD: 'flake8'
Linux black:
IMAGE_NAME: 'ubuntu-16.04'
PYTHON_VERSION: '3.6'
TOX_CMD: 'black'
Linux coverage:
IMAGE_NAME: 'ubuntu-16.04'
PYTHON_VERSION: '3.7'
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Expand Up @@ -28,4 +28,4 @@ wrapt==1.10.8
scikit-learn==0.20.3
pymongo==3.8.0
py-cpuinfo==4.0

pre-commit==1.18.0
56 changes: 27 additions & 29 deletions docs/conf.py
Expand Up @@ -19,7 +19,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
from sacred import __version__

# -- General configuration ------------------------------------------------
Expand All @@ -30,26 +30,23 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon'
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'Sacred'
copyright = '2015, Klaus Greff'
project = "Sacred"
copyright = "2015, Klaus Greff"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -61,7 +58,7 @@
# The full version, including alpha/beta/rc tags.
release = __version__

version = '.'.join(release.split('.')[:2])
version = ".".join(release.split(".")[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -75,7 +72,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -93,7 +90,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -105,15 +102,16 @@
# -- Options for HTML output ----------------------------------------------

# on_rtd is whether we are on readthedocs.org
on_rtd = os.environ.get('READTHEDOCS') == 'True'
on_rtd = os.environ.get("READTHEDOCS") == "True"

if not on_rtd: # only import and set the theme if we're building docs locally
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
except ImportError:
html_theme = 'default'
html_theme = "default"
# else: readthedocs.org uses their theme by default, so no need to specify it


Expand Down Expand Up @@ -144,7 +142,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -193,18 +191,16 @@
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'Sacreddoc'
htmlhelp_basename = "Sacreddoc"


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}
Expand All @@ -213,8 +209,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'Sacred.tex', 'Sacred Documentation',
'Klaus Greff', 'manual'),
("index", "Sacred.tex", "Sacred Documentation", "Klaus Greff", "manual")
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -242,10 +237,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'sacred', 'Sacred Documentation',
['Klaus Greff'], 1)
]
man_pages = [("index", "sacred", "Sacred Documentation", ["Klaus Greff"], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -257,9 +249,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Sacred', 'Sacred Documentation',
'Klaus Greff', 'Sacred', 'One line description of project.',
'Miscellaneous'),
(
"index",
"Sacred",
"Sacred Documentation",
"Klaus Greff",
"Sacred",
"One line description of project.",
"Miscellaneous",
)
]

# Documents to append as an appendix to all manuals.
Expand Down
2 changes: 1 addition & 1 deletion examples/01_hello_world.py
Expand Up @@ -33,4 +33,4 @@
# This function should be executed so we are decorating it with @ex.automain
@ex.automain
def main():
print('Hello world!')
print("Hello world!")
4 changes: 1 addition & 3 deletions examples/02_hello_config_dict.py
Expand Up @@ -29,9 +29,7 @@
ex = Experiment()

# We add message to the configuration of the experiment here
ex.add_config({
"message": "Hello world!"
})
ex.add_config({"message": "Hello world!"})
# Equivalent:
# ex.add_config(
# message="Hello world!"
Expand Down
2 changes: 1 addition & 1 deletion examples/03_hello_config_scope.py
Expand Up @@ -37,7 +37,7 @@

from sacred import Experiment

ex = Experiment('hello_cs') # here we name the experiment explicitly
ex = Experiment("hello_cs") # here we name the experiment explicitly


# A ConfigScope is a function like this decorated with @ex.config
Expand Down
8 changes: 4 additions & 4 deletions examples/04_captured_functions.py
Expand Up @@ -21,7 +21,7 @@

from sacred import Experiment

ex = Experiment('captured_functions')
ex = Experiment("captured_functions")


@ex.config
Expand All @@ -32,17 +32,17 @@ def cfg():
# Captured functions have access to all the configuration parameters
@ex.capture
def foo(message):
print(message.format('foo'))
print(message.format("foo"))


@ex.capture
def bar(message):
print(message.format('bar'))
print(message.format("bar"))


@ex.automain
def main():
foo() # Notice that we do not pass message here
bar() # or here
# But we can if we feel like it...
foo('Overriding the default message for {}.')
foo("Overriding the default message for {}.")
10 changes: 5 additions & 5 deletions examples/05_my_commands.py
Expand Up @@ -42,12 +42,12 @@

from sacred import Experiment

ex = Experiment('my_commands')
ex = Experiment("my_commands")


@ex.config
def cfg():
name = 'John'
name = "John"


@ex.command
Expand All @@ -57,17 +57,17 @@ def greet(name):
Uses the name from config.
"""
print('Hello {}! Nice to greet you!'.format(name))
print("Hello {}! Nice to greet you!".format(name))


@ex.command
def shout():
"""
Shout slang question for "what is up?"
"""
print('WHAZZZUUUUUUUUUUP!!!????')
print("WHAZZZUUUUUUUUUUP!!!????")


@ex.automain
def main():
print('This is just the main command. Try greet or shout.')
print("This is just the main command. Try greet or shout.")
2 changes: 1 addition & 1 deletion examples/06_randomness.py
Expand Up @@ -53,7 +53,7 @@

from sacred import Experiment

ex = Experiment('randomness')
ex = Experiment("randomness")


@ex.config
Expand Down
8 changes: 4 additions & 4 deletions examples/07_magic.py
Expand Up @@ -5,9 +5,7 @@

ex = Experiment("svm")

ex.observers.append(
FileStorageObserver.create("my_runs")
)
ex.observers.append(FileStorageObserver.create("my_runs"))


@ex.config # Configuration is defined through local variables.
Expand All @@ -26,7 +24,9 @@ def get_model(C, gamma, kernel):
@ex.automain # Using automain to enable command line integration.
def run():
X, y = datasets.load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.2)
X_train, X_test, y_train, y_test = model_selection.train_test_split(
X, y, test_size=0.2
)
clf = get_model() # Parameters are injected automatically.
clf.fit(X_train, y_train)
return clf.score(X_test, y_test)
24 changes: 14 additions & 10 deletions examples/08_less_magic.py
Expand Up @@ -5,15 +5,15 @@

ex = Experiment("svm")

ex.observers.append(
FileStorageObserver.create("my_runs")
ex.observers.append(FileStorageObserver.create("my_runs"))
ex.add_config(
{ # Configuration is explicitly defined as dictionary.
"C": 1.0,
"gamma": 0.7,
"kernel": "rbf",
"seed": 42,
}
)
ex.add_config({ # Configuration is explicitly defined as dictionary.
"C": 1.0,
"gamma": 0.7,
"kernel": "rbf",
"seed": 42
})


def get_model(C, gamma, kernel):
Expand All @@ -23,8 +23,12 @@ def get_model(C, gamma, kernel):
@ex.main # Using main, command-line arguments will not be interpreted in any special way.
def run(_config):
X, y = datasets.load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.2)
clf = get_model(_config["C"], _config["gamma"], _config["kernel"]) # Parameters are passed explicitly.
X_train, X_test, y_train, y_test = model_selection.train_test_split(
X, y, test_size=0.2
)
clf = get_model(
_config["C"], _config["gamma"], _config["kernel"]
) # Parameters are passed explicitly.
clf.fit(X_train, y_train)
return clf.score(X_test, y_test)

Expand Down

0 comments on commit f90d1f6

Please sign in to comment.