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

Orion as a service #1023

Open
wants to merge 97 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
5b297d6
init
Delaunay May 26, 2022
b95958d
Add Mongo setup script to test multi user
Delaunay May 31, 2022
6a6be5c
Bybass singletons
Delaunay May 31, 2022
e4fcf57
Change to a ExperimentClient Broker
Delaunay Jun 1, 2022
5436788
Patch more singleton
Delaunay Jun 2, 2022
c8d1ae4
Split brokers
Delaunay Jun 2, 2022
99d543b
-
Delaunay Jun 2, 2022
c02bd93
add suggest for both remote and local broker
Delaunay Jun 2, 2022
db02301
-
Delaunay Jun 2, 2022
7f4b591
-
Delaunay Jun 2, 2022
330c2cf
-
Delaunay Jun 6, 2022
eab12dc
Merge branch 'develop' of github.com:Epistimio/orion into orion_service
Delaunay Jul 27, 2022
fba0384
Merge branch 'develop' of github.com:Epistimio/orion into orion_service
Delaunay Aug 1, 2022
5ea9b01
pre-commit
Delaunay Aug 1, 2022
5c901e1
-
Delaunay Aug 2, 2022
46bab73
-
Delaunay Aug 2, 2022
71339a0
-
Delaunay Aug 2, 2022
37e792e
-
Delaunay Aug 3, 2022
0957a4b
-
Delaunay Aug 4, 2022
4c6ba50
Base client requests are working
Delaunay Aug 8, 2022
3cd9547
Update error handling
Delaunay Aug 8, 2022
23ca0b9
-
Delaunay Aug 11, 2022
7d1baba
Metrics
Delaunay Aug 15, 2022
dbc2046
-
Delaunay Aug 15, 2022
71b63f7
-
Delaunay Aug 18, 2022
674bc9e
-
Delaunay Aug 23, 2022
758ce0a
Merge branch 'develop' of github.com:Epistimio/orion into orion_service
Delaunay Aug 23, 2022
f3ec770
Add REST storage
Delaunay Aug 23, 2022
d8cf641
-
Delaunay Aug 23, 2022
ad09254
Testing
Delaunay Aug 25, 2022
232d371
Make sure MongoDB admin gets the right port
Delaunay Sep 6, 2022
681cf99
Add some variables required by the Runner
Delaunay Sep 6, 2022
8b48cfb
Fix a few last issues
Delaunay Sep 6, 2022
fbe0786
Change init order to help testing
Delaunay Sep 9, 2022
ba212ca
Add missing requests
Delaunay Sep 9, 2022
ee51d46
Add client<->server request for ExperimentClient action
Delaunay Sep 12, 2022
60574f3
-
Delaunay Sep 12, 2022
19b9832
Enable experiment_client test to run for both storage and rest api
Delaunay Sep 16, 2022
ce0111d
-
Delaunay Sep 16, 2022
eae6612
Fix a few tests
Delaunay Sep 19, 2022
8e62af9
Fix some tests
Delaunay Sep 19, 2022
f13c9c9
Fix a bunch of tests
Delaunay Sep 20, 2022
bd71ea6
Fix tests
Delaunay Sep 20, 2022
4a418fd
-
Delaunay Sep 26, 2022
8c950aa
pylint fixes
Delaunay Sep 26, 2022
d68a4a3
Remove debug assert
Delaunay Sep 26, 2022
01f3a35
remove debug code
Oct 18, 2022
fabf5dc
Add config test
Oct 18, 2022
38c4841
Add owner_id to main experiment index
Oct 19, 2022
bed7de9
Update rest client API to match regular client
Oct 19, 2022
60df77b
Merge branch 'develop' of github.com:Epistimio/orion into orion_service
Oct 19, 2022
88c4211
Delete out.txt
Delaunay Oct 20, 2022
a7d63d5
-
Oct 20, 2022
d26ecb4
Merge branch 'orion_service' of github.com:Delaunay/orion into orion_…
Oct 20, 2022
6cf8c1e
-
Oct 25, 2022
1c0889a
-
Oct 25, 2022
82af20f
-
Oct 25, 2022
c899b93
-
Oct 25, 2022
e961be8
-
Oct 25, 2022
7a1c234
commit
Oct 31, 2022
8d0dd0e
Move the services tests to its own section
Oct 31, 2022
ab9fa98
Set inserted trials with new status #1015
Oct 31, 2022
978fce6
-
Oct 31, 2022
7a3df55
add tests
Oct 31, 2022
0f46d18
update tests
Oct 31, 2022
14be107
-
Oct 31, 2022
8b4e28d
-
Oct 31, 2022
2f2dfae
-
Nov 1, 2022
13307f4
Make sure all trials gets released
Nov 8, 2022
8e088c6
-
Delaunay Nov 21, 2022
f356fb0
Merge branch 'develop' of github.com:Epistimio/orion into orion_servi…
Delaunay Nov 21, 2022
5854a17
-
Dec 8, 2022
99d670f
Merge branch 'develop' of github.com:Epistimio/orion into orion_servi…
Dec 8, 2022
2e5aa31
Merge branch 'orion_service_2' of github.com:Delaunay/orion into orio…
Dec 8, 2022
a987e19
Run all service related tests in their own block
Dec 8, 2022
f493f07
-
Dec 8, 2022
57bb8bf
Debug CI
Dec 8, 2022
d54c8d6
Make sure mongo tools are installed
Dec 9, 2022
26cb304
-
Dec 9, 2022
f8542e8
-
Dec 9, 2022
620b716
Merge branch 'develop' of github.com:Epistimio/orion into orion_servi…
Jan 11, 2023
3c0e3f2
Pylint
Jan 11, 2023
2c3093a
Merge branch 'develop' of github.com:Epistimio/orion into orion_servi…
Jan 16, 2023
8826eab
Update new tests for orion serviec
Jan 17, 2023
aed60e4
black
Jan 17, 2023
e6fbb57
update tests
Jan 17, 2023
4661da3
-
Jan 17, 2023
e39b99e
Uniformize storage env variable names
bouthilx Jan 25, 2023
338f64a
Adjust config tests for storage env var names
bouthilx Jan 25, 2023
e73b72f
Prepare release 0.2.7
notoraptor Mar 2, 2023
9a5f28d
Merge pull request #1087 from notoraptor/release-0.2.7rc
notoraptor Mar 2, 2023
b190d9b
Update backward comp test versions
notoraptor Mar 2, 2023
7411b23
Merge pull request #1089 from Epistimio/ci/sync_master_back_to_dev
Delaunay Mar 3, 2023
5abf4e5
Merge branch 'master' of github.com:Epistimio/orion into orion_service_2
Apr 13, 2023
f7f766e
-
Apr 13, 2023
98effa6
-
Apr 13, 2023
351f6dd
Merge branch 'develop' into orion_service_2
Delaunay Aug 10, 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
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,41 @@ jobs:
env_vars: PLATFORM,PYTHON
name: codecov-umbrella
fail_ci_if_error: false

service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions

- name: Install MongoDB
run: |
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
mongod --version
mongosh --version

- name: Test with tox
run: tox -e service

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
env_vars: PLATFORM,PYTHON
name: codecov-umbrella
fail_ci_if_error: false

mongodb:
needs: [pre-commit, pretest]
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ docs/src/auto_examples
docs/src/auto_tutorials
docs/src/gen_modules

out.txt

# Data and checkpoints downloaded or generated by the Profet tasks.
profet_data
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ docstring-min-length=-1
function-rgx=^(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$

# Good variable names which should always be accepted, separated by a comma
good-names=i,j,k,v,ex,Run,_,f,e,X,y,a,b,rv
good-names=i,j,k,v,ex,Run,_,f,e,X,y,a,b,rv,id

# Include a hint for the correct naming format with invalid-name
include-naming-hint=no
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exclude .pylintrc
exclude codecov.yml
exclude .mailmap
exclude .readthedocs.yml
exclude scripts/setup.sh
prune conda/
prune .github/

Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ If you use Oríon for published work, please cite our work using the following b

.. code-block:: bibtex

@software{xavier_bouthillier_2022_0_2_6,
@software{xavier_bouthillier_2023_0_2_7,
author = {Xavier Bouthillier and
Christos Tsirigotis and
François Corneau-Tremblay and
Expand All @@ -147,10 +147,10 @@ If you use Oríon for published work, please cite our work using the following b
Pascal Lamblin and
Christopher Beckham},
title = {{Epistimio/orion: Asynchronous Distributed Hyperparameter Optimization}},
month = august,
year = 2022,
month = march,
year = 2023,
publisher = {Zenodo},
version = {v0.2.6,
version = {v0.2.7,
doi = {10.5281/zenodo.3478592},
url = {https://doi.org/10.5281/zenodo.3478592}
}
Expand Down
4 changes: 3 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Roadmap
Last update August 18th, 2022
Last update March 2nd, 2023

## Next releases - Short-Term

### v0.2.8

### v0.2.7

### v0.2.6
Expand Down
188 changes: 188 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
#!/bin/bash

# Setup a mongodb server for testing
# this setup is done my IT when the DB is deployed
# set -evx

PORT=${MONGO_PORT:-"8123"}
ADDRESS=${MONGO_ADDRESS:-"localhost"}
ADMIN=${MONGO_ADMIN:-"god"}
PASSWORD=${MONGO_PASS:-"god123"}
DB_PATH=${MONGO_PATH:-"/tmp/db"}

function start_init_mongod {
# Start mongodb without Access Control, this is used to insert the admin user
# the db is then stopped and started with Access Control

if test -f "$DB_PATH/pid"; then
pid=$(cat $DB_PATH/pid)
kill -3 $pid || true
fi

rm -rf $DB_PATH
mkdir -p $DB_PATH

mongod --dbpath $DB_PATH/ --wiredTigerCacheSizeGB 1 --port $PORT --bind_ip localhost --pidfilepath $DB_PATH/pid &
sleep 1
}

function start_mongod {
# start mongodb with Access Control
mongod --auth --dbpath $DB_PATH/ --wiredTigerCacheSizeGB 1 --port $PORT --bind_ip $ADDRESS --pidfilepath $DB_PATH/pid --fork --logpath $DB_PATH/log.txt
sleep 1
}

function stop_mongod {
# mongo --dbpath $DB_PATH --shutdown

echo "$(pwd)"
pid=$(cat $DB_PATH/pid)
kill -s TERM $pid
rm -rf $DB_PATH/pid
sleep 1
}

function add_admin_user {
# create an admin user
# userAdminAnyDatabase: create users, grant & revoke roles, create and modify roles

CMD=$(cat <<EOM
use admin
db.createUser({
user: "$ADMIN",
pwd: "$PASSWORD",
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" },
]
})
EOM
)

echo "$CMD" | mongosh --port $PORT

add_user $ADMIN $PASSWORD
}

function add_user {
# Create a user for the orion database
#
# How to make a group setup
# - make a Token => Group
# - Token => User => Group

username=$1
password=$2
token=$3

CMD=$(cat << EOM
use orion
db.createUser({
user: "$username",
pwd: "$password",
roles: [
{ role: "readWrite", db: "orion" }
]
})

db.users.insertOne({
username: "$username",
password: "$password",
token: "$token",
})
EOM
)

echo "$CMD" | mongosh "mongodb://$ADDRESS:$PORT" --authenticationDatabase "admin" -u $ADMIN -p $PASSWORD
}


ASCENDING=1
DESCENDING=-1

function ensure_indexes {
# User will have limited access to the collection
# so orion's client cannot do this

CMD=$(cat <<EOM
use orion

db.experiments.createIndex(
{
"name": 1,
"version": 1,
"owner_id": 1
},
{
unique: true
}
)
db.experiments.createIndex(
{
"metadata.datetime": 1
}
)

db.trials.createIndex(
{
"experiment": 1,
"id": 1
},
{
unique: true
}
)
db.trials.createIndex(
{
"experiment": 1
}
)
db.trials.createIndex(
{
"status": 1
}
)
db.trials.createIndex(
{
"results": 1
}
)
db.trials.createIndex(
{
"start_time": 1
}
)
db.trials.createIndex(
{
"end_time": -1
}
)
db.algo.createIndex(
{
"experiment": 1
}
)
EOM
)

echo "$CMD" | mongosh --port $PORT
}

function launch {
# Setup a mongodb for testing
start_init_mongod
add_admin_user
ensure_indexes
stop_mongod

# Start mongodb with access control
start_mongod

add_user User1 Pass1 Tok1
add_user User2 Pass2 Tok2
add_user User3 Pass3 Tok3
}

export MONGO_RUNNING="${DB_PATH}"
launch

4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"orion.executor",
"orion.plotting",
"orion.serving",
"orion.service",
"orion.service.broker",
"orion.service.client",
"orion.storage",
"orion.testing",
]
Expand Down Expand Up @@ -138,6 +141,7 @@
"BaseStorageProtocol": [
"track = orion.storage.track:Track",
"legacy = orion.storage.legacy:Legacy",
"rest = orion.storage.rest:RESTStorage",
],
"BaseExecutor": [
"singleexecutor = orion.executor.single_backend:SingleExecutor",
Expand Down
39 changes: 39 additions & 0 deletions src/orion/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,44 @@ def build_experiment(
If the algorithm or storage specified is not properly installed.

"""
return ExperimentClient.create_experiment(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move this to ExpelimentClient.create_experiment which calls _build_experiment? Is it to support different subclasses of ExperimentClient?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

name,
version=version,
space=space,
algorithms=algorithms,
strategy=strategy,
max_trials=max_trials,
max_broken=max_broken,
storage=storage,
branching=branching,
max_idle_time=max_idle_time,
heartbeat=heartbeat,
working_dir=working_dir,
debug=debug,
knowledge_base=knowledge_base,
executor=executor,
)


# pylint: disable=too-many-arguments
def _build_experiment(
name,
version=None,
space=None,
algorithms=None,
strategy=None,
max_trials=None,
max_broken=None,
storage=None,
branching=None,
max_idle_time=None,
heartbeat=None,
working_dir=None,
debug=False,
knowledge_base: KnowledgeBase | dict | None = None,
executor=None,
):

if max_idle_time:
log.warning(
"max_idle_time is deprecated. Use experiment.workon(idle_timeout) instead."
Expand All @@ -230,6 +268,7 @@ def build_experiment(
knowledge_base=knowledge_base,
)
except RaceCondition:
log.debug("Try creating a new experiment again")
# Try again, but if it fails again, raise. Race conditions due to version increment should
# only occur once in a short window of time unless code version is changing at a crazy pace.
try:
Expand Down
Loading