Ejemplo n.º 1
0
def stop_experiment(experiment_id,
                    api=experiments_api,
                    logger_=logger.Logger()):
    url = "/experiments/{}/stop/".format(experiment_id)
    response = api.put(url)
    logger_.log_response(response, "Experiment stopped",
                         "Unknown error while stopping the experiment")
Ejemplo n.º 2
0
    def __init__(self, logger_=None):
        """

        :param logger_: gradient.logger
        """
        self.logger = logger_ or logger.Logger()
        self.archive_path = None
        self.archive_basename = None
Ejemplo n.º 3
0
def get_deployments_list(api_key=None, **filters):
    del_if_value_is_none(filters)
    deployment_client = get_deployment_client(api_key)
    command = deployments_commands.ListDeploymentsCommand(
        deployment_client=deployment_client)
    try:
        command.execute(filters=filters)
    except exceptions.ApplicationError as e:
        logger.Logger().error(e)
Ejemplo n.º 4
0
 def __init__(self,
              api_url,
              headers=None,
              api_key=None,
              logger_=logger.Logger()):
     self.api_url = api_url
     headers = headers or default_headers
     self.headers = headers.copy()
     if api_key:
         self.api_key = api_key
     self.logger = logger_
Ejemplo n.º 5
0
def get_experiment_details(experiment_id,
                           api=experiments_api,
                           logger_=logger.Logger()):
    url = "/experiments/{}/".format(experiment_id)
    response = api.get(url)
    details = response.content
    if response.ok:
        try:
            experiment = response.json()["data"]
            details = _make_details_table(experiment)
        except (ValueError, KeyError):
            logger_.error("Error parsing response data")

    logger_.log_response(
        response, details,
        "Unknown error while retrieving details of the experiment")
Ejemplo n.º 6
0
 def __init__(self, deployment_client, logger_=gradient_logger.Logger()):
     self.deployment_client = deployment_client
     self.logger = logger_
Ejemplo n.º 7
0
def get_workspace_handler(api_key):
    client = http_client.API(config.CONFIG_EXPERIMENTS_HOST, api_key=api_key)
    logger_ = logger.Logger()
    workspace_handler = workspace.S3WorkspaceHandlerWithProgressbar(experiments_api=client, logger_=logger_)
    return workspace_handler
Ejemplo n.º 8
0
def get_workspace_handler():
    logger_ = logger.Logger()
    workspace_handler = WorkspaceHandler(logger_=logger_)
    return workspace_handler
Ejemplo n.º 9
0
import platform
import sys
from distutils.version import StrictVersion

import six

from gradient import logger
from gradient.version import version

if six.PY2:
    import xmlrpclib
else:
    import xmlrpc.client as xmlrpclib

logger = logger.Logger()


class PackageNotFoundError(Exception):
    pass


class VersionChecker(object):
    def is_up_to_date(self, module_name, current_version):
        version_in_repository = self.get_version_from_repository(module_name)

        up_to_date = StrictVersion(current_version) >= StrictVersion(
            version_in_repository)
        return up_to_date, version_in_repository

    def get_version_from_repository(
            self, module_name, repository_url="http://pypi.python.org/pypi"):
Ejemplo n.º 10
0
 def __init__(self, api=None, logger_=logger.Logger()):
     self.api = api
     self.logger = logger_
Ejemplo n.º 11
0
def get_deployment_client(api_key):
    deployment_client = DeploymentsClient(api_key=api_key,
                                          logger=logger.Logger())
    return deployment_client