Skip to content

Commit

Permalink
Merge branch 'master' into release/0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
narenst committed Aug 4, 2017
2 parents c1451eb + b9f1e1c commit 0274792
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 50 deletions.
6 changes: 3 additions & 3 deletions floyd/cli/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def print_data(data_sources):
if not data_sources:
return

headers = ["DATA ID", "CREATED", "STATUS", "DISK USAGE", "NAME"]
headers = ["DATA NAME", "CREATED", "STATUS", "DISK USAGE"]
data_list = []
for data_source in data_sources:
data_list.append([data_source.id, data_source.created_pretty,
data_source.state, data_source.size, data_source.name])
data_list.append([data_source.name, data_source.created_pretty,
data_source.state, data_source.size])
floyd_logger.info(tabulate(data_list, headers=headers))


Expand Down
12 changes: 6 additions & 6 deletions floyd/cli/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import floyd
from floyd.cli.utils import get_module_task_instance_id
from floyd.client.common import get_url_contents
from floyd.client.experiment import ExperimentClient
from floyd.client.module import ModuleClient
from floyd.client.project import ProjectClient
from floyd.client.resource import ResourceClient
from floyd.client.task_instance import TaskInstanceClient
from floyd.manager.experiment_config import ExperimentConfigManager
from floyd.manager.floyd_ignore import FloydIgnoreManager
Expand Down Expand Up @@ -62,11 +62,11 @@ def print_experiments(experiments):
"""
Prints expt details in a table. Includes urls and mode parameters
"""
headers = ["RUN ID", "CREATED", "STATUS", "DURATION(s)", "NAME", "INSTANCE", "DESCRIPTION"]
headers = ["JOB NAME", "CREATED", "STATUS", "DURATION(s)", "INSTANCE", "DESCRIPTION"]
expt_list = []
for experiment in experiments:
expt_list.append([experiment.id, experiment.created_pretty, experiment.state,
experiment.duration_rounded, experiment.name,
expt_list.append([experiment.name, experiment.created_pretty, experiment.state,
experiment.duration_rounded,
experiment.instance_type_trimmed, experiment.description])
floyd_logger.info(tabulate(expt_list, headers=headers))

Expand Down Expand Up @@ -142,14 +142,14 @@ def logs(id, url, tail, sleep_duration=1):
current_shell_output = ""
while True:
# Get the logs in a loop and log the new lines
log_file_contents = get_url_contents(log_url)
log_file_contents = ResourceClient().get_content(task_instance.log_id)
print_output = log_file_contents[len(current_shell_output):]
if len(print_output.strip()):
floyd_logger.info(print_output)
current_shell_output = log_file_contents
sleep(sleep_duration)
else:
log_file_contents = get_url_contents(log_url)
log_file_contents = ResourceClient().get_content(task_instance.log_id)
if len(log_file_contents.strip()):
floyd_logger.info(log_file_contents)
else:
Expand Down
3 changes: 1 addition & 2 deletions floyd/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ def run(ctx, gpu, env, message, data, mode, open, tensorboard, command):
expt_info = expt_cli.create(experiment_request)
floyd_logger.debug("Created job : {}".format(expt_info['id']))

table_output = [["RUN ID", "NAME"],
[expt_info['id'], expt_info['name']]]
table_output = [["JOB NAME"], [expt_info['name']]]
floyd_logger.info(tabulate(table_output, headers="firstrow"))
floyd_logger.info("")

Expand Down
14 changes: 0 additions & 14 deletions floyd/client/common.py
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@
import requests

from floyd.exceptions import FloydException


def get_url_contents(url):
"""
Downloads the content of the url and returns it
"""
response = requests.get(url)
if response.status_code == 200:
return response.content.decode(response.encoding)
else:
raise FloydException("Failed to get contents of the url : {}".format(url))
8 changes: 8 additions & 0 deletions floyd/client/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def get(self, resource_id):
floyd_logger.info("Resource %s: ERROR! %s", resource_id, e.message)
return None

def get_content(self, resource_id):
try:
response = self.request('GET', self.URL_PREFIX + resource_id + "?content=true")
return response.content.decode(response.encoding)
except FloydException as e:
floyd_logger.debug("Resource %s: ERROR! %s", resource_id, e.message)
return None

def wait_for_ready(self, resource_id):
sleep(2) # initial wait of 2 seconds
ready = False
Expand Down
5 changes: 4 additions & 1 deletion floyd/log.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import logging
import sys

logger = logging.getLogger('floyd')


def configure_logger(verbose):
log_level = logging.DEBUG if verbose else logging.INFO
logging.basicConfig(format='%(message)s', level=log_level)
logging.basicConfig(format='%(message)s',
level=log_level,
stream=sys.stdout)
24 changes: 0 additions & 24 deletions tests/client/common_test.py

This file was deleted.

0 comments on commit 0274792

Please sign in to comment.