Skip to content

Commit

Permalink
Merge pull request #83 from houqp/release/0.10
Browse files Browse the repository at this point in the history
release 0.10.5
  • Loading branch information
narenst authored Aug 8, 2017
2 parents 2b4a1dd + 7dc99f9 commit 7cacd9b
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.10.4
current_version = 0.10.5
commit = True
tag = False

Expand Down
5 changes: 3 additions & 2 deletions floyd/cli/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import floyd
from floyd.client.data import DataClient
from floyd.client.dataset import DatasetClient
from floyd.client.resource import ResourceClient
from floyd.manager.auth_config import AuthConfigManager
from floyd.manager.data_config import DataConfig, DataConfigManager
from floyd.log import logger as floyd_logger
Expand Down Expand Up @@ -133,8 +134,8 @@ def output(id, url):
if not data_source:
sys.exit()

data_url = "{}/api/v1/resources/{}?content=true".format(floyd.floyd_host,
data_source.resource_id)
resource = ResourceClient().get(data_source.resource_id)
data_url = "{}/viewer/{}".format(floyd.floyd_host, resource.uri)
if url:
floyd_logger.info(data_url)
else:
Expand Down
4 changes: 2 additions & 2 deletions floyd/cli/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def output(id, url, download):
experiment = ExperimentClient().get(id)
task_instance = TaskInstanceClient().get(get_module_task_instance_id(experiment.task_instances))
if "output" in task_instance.output_ids:
output_dir_url = "{}/api/v1/resources/{}?content=true".format(floyd.floyd_host,
task_instance.output_ids["output"])
resource = ResourceClient().get(task_instance.output_ids["output"])
output_dir_url = "{}/viewer/{}".format(floyd.floyd_host, resource.uri)
if url:
floyd_logger.info(output_dir_url)
else:
Expand Down
6 changes: 5 additions & 1 deletion floyd/cli/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
PROJECT_NAME = "floyd-cli"


def pip_upgrade():
pip.main(["install", "--upgrade", PROJECT_NAME])


@click.command()
def version():
"""
Expand All @@ -23,6 +27,6 @@ def upgrade():
Upgrade floyd command line
"""
try:
pip.main(["install", "--upgrade", PROJECT_NAME])
pip_upgrade()
except Exception as e:
floyd_logger.error(e)
22 changes: 15 additions & 7 deletions floyd/client/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
from floyd.log import logger as floyd_logger


def get_unignored_file_paths(ignore_list=[], whitelist=[]):
def get_unignored_file_paths(ignore_list=None, whitelist=None):
"""
Given an ignore_list and a whitelist of glob patterns, returns the list of
unignored file paths in the current directory and its subdirectories
"""
unignored_files = []
if ignore_list is None:
ignore_list = []
if whitelist is None:
whitelist = []

for root, dirs, files in os.walk("."):
floyd_logger.debug("Root:{}, Dirs:{}".format(root, dirs))
floyd_logger.debug("Root:%s, Dirs:%s", root, dirs)

if ignore_path(unix_style_path(root), ignore_list, whitelist):
# Reset dirs to avoid going further down this directory.
Expand All @@ -28,24 +32,28 @@ def get_unignored_file_paths(ignore_list=[], whitelist=[]):
# that file is excluded."
# https://git-scm.com/docs/gitignore#_pattern_format
dirs[:] = []
floyd_logger.debug("Ignoring directory : {}".format(root))
floyd_logger.debug("Ignoring directory : %s", root)
continue

for file_name in files:
file_path = unix_style_path(os.path.join(root, file_name))
if ignore_path(file_path, ignore_list, whitelist):
floyd_logger.debug("Ignoring file : {}".format(file_name))
floyd_logger.debug("Ignoring file : %s", file_name)
continue

unignored_files.append(os.path.join(root, file_name))

return unignored_files

def ignore_path(path, ignore_list=[], whitelist=[]):
def ignore_path(path, ignore_list=None, whitelist=None):
"""
Returns a boolean indicating if a path should be ignored given an
ignore_list and a whitelist of glob patterns.
"""
if ignore_list is None:
ignore_list = []
if whitelist is None:
whitelist = []
return matches_glob_list(path, ignore_list) and not matches_glob_list(path, whitelist)

def matches_glob_list(path, glob_list):
Expand All @@ -71,8 +79,8 @@ def get_files_in_current_directory(file_type):

ignore_list, whitelist = FloydIgnoreManager.get_lists()

floyd_logger.debug("Ignoring: {}".format(ignore_list))
floyd_logger.debug("Whitelisting: {}".format(whitelist))
floyd_logger.debug("Ignoring: %s", ignore_list)
floyd_logger.debug("Whitelisting: %s", whitelist)

file_paths = get_unignored_file_paths(ignore_list, whitelist)

Expand Down
1 change: 0 additions & 1 deletion floyd/client/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def create(self, module):
finally:
# always make sure we clear the console
bar.done()
floyd_logger.info("Done")
return response.json().get("id")

def delete(self, id):
Expand Down
3 changes: 2 additions & 1 deletion floyd/client/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def get(self, resource_id):
try:
response = self.request('GET', self.URL_PREFIX + resource_id)
resource_dict = response.json()
return Resource.from_dict(resource_dict)
resource = Resource.from_dict(resource_dict)
return resource
except FloydException as e:
floyd_logger.info("Resource %s: ERROR! %s", resource_id, e.message)
return None
Expand Down
10 changes: 6 additions & 4 deletions floyd/client/tus_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def initialize_upload(self,
location = ""
except requests.exceptions.ConnectionError as e:
floyd_logger.error(
"Cannot connect to the Floyd data upload server. "
"Cannot connect to the Floyd data upload server for upload url. "
"Check your internet connection.")
location = ""

Expand All @@ -83,7 +83,7 @@ def resume_upload(self,
return False
except requests.exceptions.ConnectionError as e:
floyd_logger.error(
"Cannot connect to the Floyd data upload server. "
"Cannot connect to the Floyd data upload server for offset. "
"Check your internet connection.")
return False

Expand All @@ -107,7 +107,9 @@ def resume_upload(self,
e.message)
return False
except requests.exceptions.ConnectionError as e:
floyd_logger.error("Cannot connect to the Floyd data upload server. Check your internet connection.")
floyd_logger.error(
"Cannot connect to the Floyd data upload server. "
"Check your internet connection.")
return False

# Complete the progress bar with one more call to show()
Expand All @@ -127,7 +129,7 @@ def _get_offset(self, file_endpoint, headers=None, auth=None):
self.check_response_status(response)

offset = int(response.headers["Upload-Offset"])
floyd_logger.debug("offset:{}".format(offset))
floyd_logger.debug("offset: %s", offset)
return offset

def _upload_chunk(self, data, offset, file_endpoint, headers=None, auth=None):
Expand Down
114 changes: 3 additions & 111 deletions floyd/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
parts
sdist
var
*.pyc
*.swp
.DS_Store
"""

CPU_INSTANCE_TYPE = "cpu_high"
Expand All @@ -81,114 +84,3 @@
And init a floyd project inside that.
floyd init --project example-proj
"""

# SimCity4 Loading messages
# https://www.gamefaqs.com/pc/561176-simcity-4/faqs/22135
# Credits: EA Games
LOADING_MESSAGES = [
"Adding Hidden Layers",
"Adjusting Bell Curves",
"Aesthesizing Industrial Grade Containers",
"Aligning Covariance Matrices",
"Applying Feng Shui Backprops",
"Applying Theano Soda Layer",
"Asserting Packed Exemplars",
"Attempting to Lock Back-Buffer",
"Binding Sampling Root System",
"Breeding Neural Nets",
"Building Deep Data Trees",
"Bureacritizing Deep Learning Bureaucracies",
"Calculating Inverse Probability Matrices",
"Calculating SGD Expectoration Trajectory",
"Calibrating Blue Skies",
"Charging Ozone Layer",
"Coalescing Cloud Formations",
"Cohorting Exemplars",
"Collecting Meteor Particles",
"Compounding Inert Tessellations",
"Compressing Fish Files",
"Computing Optimal Bin Packing",
"Concatenating Sub-Contractors",
"Containing Existential Buffer",
"Debarking Ark Ramp",
"Debunching Unionized Commercial Services",
"Deciding What Message to Display Next",
"Decomposing Singular Values",
"Decrementing Tectonic Plates",
"Deleting Ferry Routes",
"Depixelating Inner Mountain Surface Back Faces",
"Depositing Slush Funds",
"Destabilizing Economic Indicators",
"Determining Width of Blast Fronts",
"Deunionizing Bulldozers",
"Dicing Trained Models",
"Diluting Livestock Nutrition Variables",
"Downloading Satellite Terrain Data",
"Exposing Flash Variables to Streak System",
"Extracting Gradient Resources",
"Factoring Pay Scale",
"Fixing Election Outcome Matrix",
"Flood-Filling Ground Water",
"Flushing Pipe Network",
"Gathering Particle Sources",
"Generating Scheduled Jobs",
"Gesticulating Mimes",
"Graphing Container Migration",
"Hiding Willio Webnet Mask",
"Implementing Impeachment Routine",
"Increasing Accuracy of RCI Simulators",
"Increasing Neural Magmafacation",
"Initializing My Sim Tracking Mechanism",
"Initializing CNN Timetable",
"Initializing Robotic Click-Path AI",
"Inserting Sublimated Messages",
"Integrating Multidimensional Curves",
"Integrating Illumination Form Factors",
"Integrating Population Graphs",
"Iterating Cellular Automata",
"Lecturing Errant Subsystems",
"Mixing Dropouts in Genetic Pool",
"Modeling Object Components",
"Mopping Occupant Leaks",
"Normalizing Power",
"Obfuscating Quigley Matrix",
"Overconstraining Dirty Industry Calculations",
"Partitioning City Grid Singularities",
"Perturbing Matrices",
"Pixalating Overfitting Patches",
"Polishing Water Highlights",
"Populating Lot Templates",
"Preparing Sprites for Random Walks",
"Prioritizing Landmarks",
"Projecting Law Enforcement Pastry Intake",
"Realigning Alternate Time Frames",
"Reconfiguring User Mental Processes",
"Relaxing Splines",
"Removing Road Network Speed Bumps",
"Removing Texture Gradients",
"Removing Vehicle Avoidance Behavior",
"Resolving GUID Conflict",
"Reticulating Splines",
"Retracting Phong Shader",
"Retrieving from Back Store",
"Reverse Engineering Image Consultant",
"Routing Neural Network Infanstructure",
"Scrubbing Terrain",
"Searching for Llamas",
"Seeding Architecture Simulation Parameters",
"Sequencing Particles",
"Setting Advisor Moods",
"Setting Inner Deity Indicators",
"Setting Universal Physical Constants",
"Sonically Enhancing Occupant-Free Timber",
"Speculating Stock Market Indices",
"Splatting Transforms",
"Stratifying Ground Layers",
"Sub-Sampling Water Data",
"Synthesizing Gravity",
"Synthesizing Wavelets",
"Time-Compressing Simulator Clock",
"Unable to Reveal Current Activity",
"Weathering Buildings",
"Zeroing Crime Network"
]
21 changes: 14 additions & 7 deletions floyd/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click
import sys
from distutils.version import LooseVersion
import pkg_resources

Expand Down Expand Up @@ -33,16 +34,22 @@ def check_cli_version():
server_version = VersionClient().get_cli_version()
current_version = pkg_resources.require("floyd-cli")[0].version
if LooseVersion(current_version) < LooseVersion(server_version.min_version):
raise FloydException("""
Your version of CLI ({}) is no longer compatible with server. Run:
print("""
Your version of CLI (%s) is no longer compatible with server.""" % current_version)
if click.confirm('Do you want to upgrade to version %s now?' % server_version.latest_version):
from floyd.cli.version import pip_upgrade
pip_upgrade()
sys.exit(0)
else:
print("""Your can manually run:
pip install -U floyd-cli
to upgrade to the latest version ({})
""".format(current_version, server_version.latest_version))
if LooseVersion(current_version) < LooseVersion(server_version.latest_version):
to upgrade to the latest version (%s))""" % server_version.latest_version)
sys.exit(0)
elif LooseVersion(current_version) < LooseVersion(server_version.latest_version):
print("""
New version of CLI ({}) is now available. To upgrade run:
New version of CLI (%s) is now available. To upgrade run:
pip install -U floyd-cli
""".format(server_version.latest_version))
""" % server_version.latest_version)


def add_commands(cli):
Expand Down
6 changes: 4 additions & 2 deletions floyd/manager/floyd_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class FloydIgnoreManager(object):
@classmethod
def init(cls):
if os.path.isfile(cls.CONFIG_FILE_PATH):
floyd_logger.debug("floyd ignore file already present at {}".format(cls.CONFIG_FILE_PATH))
floyd_logger.debug("floyd ignore file already present at %s",
cls.CONFIG_FILE_PATH)
return

floyd_logger.debug("Setting default floyd ignore in the file {}".format(cls.CONFIG_FILE_PATH))
floyd_logger.debug("Setting default floyd ignore in the file %s",
cls.CONFIG_FILE_PATH)

with open(cls.CONFIG_FILE_PATH, "w") as config_file:
config_file.write(DEFAULT_FLOYD_IGNORE_LIST)
Expand Down
10 changes: 7 additions & 3 deletions floyd/model/resource.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from marshmallow import Schema, fields
from marshmallow import Schema, fields, post_load
from floyd.model.base import BaseModel


Expand All @@ -11,19 +11,23 @@ class ResourceSchema(Schema):
date_finalized = fields.DateTime()
date_last_updated = fields.DateTime()

@post_load
def make_resource(self, data):
return Resource(**data)


class Resource(BaseModel):
schema = ResourceSchema(strict=True)

def __init__(self,
resource_id,
id,
uri,
state,
resource_type,
size,
date_finalized,
date_last_updated):
self.id = resource_id
self.id = id
self.uri = uri
self.state = state
self.resource_type = resource_type
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import find_packages, setup

project = "floyd-cli"
version = "0.10.4"
version = "0.10.5"

with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
long_description = readme.read()
Expand Down

0 comments on commit 7cacd9b

Please sign in to comment.