-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from Epistimio/release-v0.1.7rc2
Release v0.1.7rc2
- Loading branch information
Showing
53 changed files
with
1,359 additions
and
254 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
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 |
---|---|---|
|
@@ -12,6 +12,5 @@ Command lines | |
cli/hunt | ||
cli/insert | ||
cli/init_only | ||
cli/setup | ||
cli/test_db | ||
cli/db | ||
cli/evc |
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,12 @@ | ||
db commands | ||
=========== | ||
|
||
.. automodule:: orion.core.cli.db_main | ||
:members: | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: DB command line modules | ||
|
||
db/test | ||
db/setup |
2 changes: 1 addition & 1 deletion
2
docs/src/code/core/cli/setup.rst → docs/src/code/core/cli/db/setup.rst
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
setup command | ||
============= | ||
|
||
# .. automodule:: orion.core.cli.setup | ||
# .. automodule:: orion.core.cli.db.setup | ||
# :members: |
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,5 @@ | ||
db test command | ||
=============== | ||
|
||
.. automodule:: orion.core.cli.db.test | ||
:members: |
This file was deleted.
Oops, something went wrong.
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
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,11 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
:mod:`orion.core.cli.db` -- Functions that define console scripts for database | ||
============================================================================== | ||
.. module:: cli | ||
:platform: Unix | ||
:synopsis: Commands to maintain database | ||
""" |
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,85 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
:mod:`orion.core.cli.db.setup` -- Module running the setup command | ||
=============================================================== | ||
.. module:: setup | ||
:platform: Unix | ||
:synopsis: Creates a configurarion file for the database. | ||
""" | ||
|
||
import logging | ||
import os | ||
|
||
import yaml | ||
|
||
import orion.core | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def add_subparser(parser): | ||
"""Return the parser that needs to be used for this command""" | ||
setup_parser = parser.add_parser('setup', help='setup help') | ||
|
||
setup_parser.set_defaults(func=main) | ||
|
||
return setup_parser | ||
|
||
|
||
def ask_question(question, default=None): | ||
"""Ask a question to the user and receive an answer. | ||
Parameters | ||
---------- | ||
question: str | ||
The question to be asked. | ||
default: str | ||
The default value to use if the user enters nothing. | ||
Returns | ||
------- | ||
str | ||
The answer provided by the user. | ||
""" | ||
if default is not None: | ||
question = question + " (default: {}) ".format(default) | ||
|
||
answer = input(question) | ||
|
||
if answer.strip() == "": | ||
return default | ||
|
||
return answer | ||
|
||
|
||
# pylint: disable = unused-argument | ||
def main(*args): | ||
"""Build a configuration file.""" | ||
default_file = orion.core.DEF_CONFIG_FILES_PATHS[-1] | ||
|
||
if os.path.exists(default_file): | ||
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), "n") | ||
|
||
if cancel.strip().lower() == 'n': | ||
return | ||
|
||
_type = ask_question("Enter the database type: ", "mongodb") | ||
name = ask_question("Enter the database name: ", "test") | ||
host = ask_question("Enter the database host: ", "localhost") | ||
|
||
config = {'database': {'type': _type, 'name': name, 'host': host}} | ||
|
||
print("Default configuration file will be saved at: ") | ||
print(default_file) | ||
|
||
dirs = '/'.join(default_file.split('/')[:-1]) | ||
os.makedirs(dirs, exist_ok=True) | ||
|
||
with open(default_file, 'w') as output: | ||
yaml.dump(config, output, default_flow_style=False) |
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,57 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
:mod:`orion.core.cli.db.test` -- Module to check if the DB worrks | ||
================================================================= | ||
.. module:: test_db | ||
:platform: Unix | ||
:synopsis: Runs multiple checks to see if the database was correctly setup. | ||
""" | ||
import argparse | ||
import logging | ||
|
||
from orion.core.cli.checks.creation import CreationStage | ||
from orion.core.cli.checks.operations import OperationsStage | ||
from orion.core.cli.checks.presence import PresenceStage | ||
from orion.core.io.experiment_builder import ExperimentBuilder | ||
from orion.core.utils.exceptions import CheckError | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def add_subparser(parser): | ||
"""Add the subparser that needs to be used for this command""" | ||
test_db_parser = parser.add_parser('test', help='test_db help') | ||
|
||
test_db_parser.add_argument('-c', '--config', type=argparse.FileType('r'), | ||
metavar='path-to-config', help="user provided " | ||
"orion configuration file") | ||
|
||
test_db_parser.set_defaults(func=main) | ||
|
||
return test_db_parser | ||
|
||
|
||
def main(args): | ||
"""Run through all checks for database.""" | ||
experiment_builder = ExperimentBuilder() | ||
presence_stage = PresenceStage(experiment_builder, args) | ||
creation_stage = CreationStage(presence_stage) | ||
operations_stage = OperationsStage(creation_stage) | ||
stages = [presence_stage, creation_stage, operations_stage] | ||
|
||
for stage in stages: | ||
for check in stage.checks(): | ||
print(check.__doc__, end='.. ') | ||
try: | ||
status, msg = check() | ||
print(status) | ||
if status == "Skipping": | ||
print(msg) | ||
except CheckError as ex: | ||
print("Failure") | ||
print(ex) | ||
|
||
stage.post_stage() |
Oops, something went wrong.