-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional test for user script and fix bug
The `OrionCmdlineParser` formatting was not using the `config_prefix` attribute to recreate the configuration file path.
- Loading branch information
Showing
5 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
"""Simple one dimensional example for a possible user's script.""" | ||
import argparse | ||
|
||
import yaml | ||
|
||
from orion.client import report_results | ||
|
||
|
||
def function(x): | ||
"""Evaluate partial information of a quadratic.""" | ||
z = x - 34.56789 | ||
return 4 * z**2 + 23.4, 8 * z | ||
|
||
|
||
def execute(): | ||
"""Execute a simple pipeline as an example.""" | ||
# 1. Receive inputs as you want | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--configuration', required=True) | ||
inputs = parser.parse_args() | ||
|
||
with open(inputs.configuration, 'r') as f: | ||
config = yaml.load(f) | ||
|
||
# 2. Perform computations | ||
|
||
y, dy = function(config['x']) | ||
|
||
# 3. Gather and report results | ||
results = list() | ||
results.append(dict( | ||
name='example_objective', | ||
type='objective', | ||
value=y)) | ||
results.append(dict( | ||
name='example_gradient', | ||
type='gradient', | ||
value=[dy])) | ||
|
||
report_results(results) | ||
|
||
|
||
if __name__ == "__main__": | ||
execute() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: voila_voici | ||
|
||
pool_size: 1 | ||
max_trials: 100 | ||
|
||
algorithms: | ||
gradient_descent: | ||
learning_rate: 0.1 | ||
# dx_tolerance: 1e-7 | ||
|
||
user_script_config: configuration | ||
working_dir: ./ | ||
|
||
producer: | ||
strategy: NoParallelStrategy | ||
|
||
database: | ||
type: 'mongodb' | ||
name: 'orion_test' | ||
host: 'mongodb://user:pass@localhost' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters