Skip to content

Commit

Permalink
Merge pull request #203 from datmo/runs
Browse files Browse the repository at this point in the history
Creating runs and workspace
  • Loading branch information
asampat3090 committed Jun 26, 2018
2 parents 9c2251d + 56e5e93 commit dfbc498
Show file tree
Hide file tree
Showing 30 changed files with 1,589 additions and 380 deletions.
49 changes: 2 additions & 47 deletions datmo/cli/command/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
from datmo.core.util.i18n import get as __
from datmo.cli.driver.helper import Helper
from datmo.cli.command.base import BaseCommand
from datmo.core.util.spinner import Spinner
from datmo.core.util.misc_functions import mutually_exclusive
from datmo.core.controller.project import ProjectController
from datmo.core.controller.environment.environment import EnvironmentController, EnvironmentDoesNotExist
from datmo.core.controller.task import TaskController


class ProjectCommand(BaseCommand):
def __init__(self, cli_helper):
super(ProjectCommand, self).__init__(cli_helper)
self.project_controller = ProjectController()
self.spinner = Spinner()

def init(self, name, description):
"""Initialize command
Expand Down Expand Up @@ -166,7 +162,7 @@ def status(self):
return status_dict, latest_snapshot, ascending_unstaged_tasks

def cleanup(self):
# Prompt user to ensure they would like to remove all datmo information
# Prompt user to ensure they would like to remove datmo information along with environment and files folder
response = self.cli_helper.prompt_bool(
__("prompt", "cli.project.cleanup.confirm"))

Expand Down Expand Up @@ -195,45 +191,4 @@ def cleanup(self):
"name": self.project_controller.model.name,
"path": self.project_controller.home
}))
return False

@Helper.notify_environment_active(ProjectController)
@Helper.notify_no_project_found
def notebook(self, **kwargs):
self.cli_helper.echo(__("info", "cli.project.notebook"))
self.task_controller = TaskController()

# Creating input dictionaries
snapshot_dict = {}

# Environment
if kwargs.get("environment_id", None) or kwargs.get(
"environment_paths", None):
mutually_exclusive_args = ["environment_id", "environment_paths"]
mutually_exclusive(mutually_exclusive_args, kwargs, snapshot_dict)

task_dict = {
"ports": ["8888:8888"],
"command_list": ["jupyter", "notebook"],
"mem_limit": kwargs["mem_limit"]
}

# Pass in the task
try:
self.spinner.start()
# Create the task object
task_obj = self.task_controller.create()
updated_task_obj = self.task_controller.run(
task_obj.id, snapshot_dict=snapshot_dict, task_dict=task_dict)
except Exception as e:
self.logger.error("%s %s" % (e, task_dict))
self.cli_helper.echo(
__("error", "cli.project.notebook", task_obj.id))
return False
finally:
self.spinner.stop()

self.cli_helper.echo(
"Ran notebook with task id: %s" % updated_task_obj.id)

return updated_task_obj
return False

0 comments on commit dfbc498

Please sign in to comment.