Esempio n. 1
0
    def execute(self, deployment_id, **kwargs):
        self._handle_workspace(kwargs)

        with halo.Halo(text="Updating deployment data", spinner="dots"):
            self.client.update(deployment_id, **kwargs)

        self.logger.log("Deployment data updated")
Esempio n. 2
0
    def execute(self, json_):
        json_, data = self._handle_workspace(json_)

        with halo.Halo(text=self.SPINNER_MESSAGE, spinner="dots"):
            job_id = self._create(json_, data)

        self.logger.log(self.CREATE_SUCCESS_MESSAGE_TEMPLATE.format(job_id))
        self.logger.log(self.get_instance_url(job_id))
Esempio n. 3
0
    def execute(self, **kwargs):
        with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE, spinner="dots"):
            try:
                instances = self.client.artifacts_list(**kwargs)
            except sdk_exceptions.GradientSdkError as e:
                raise exceptions.ReceivingDataFailedError(e)

        self._log_objects_list(instances, kwargs)
Esempio n. 4
0
 def execute(self, **kwargs):
     with halo.Halo(text="Creating new experiment", spinner="dots"):
         try:
             deployment_id = self.deployment_client.create(**kwargs)
         except api_sdk.GradientSdkError as e:
             self.logger.error(e)
         else:
             self.logger.log(
                 "New deployment created with id: {}".format(deployment_id))
Esempio n. 5
0
    def execute(self, **kwargs):
        self._handle_auth(kwargs)
        self._handle_workspace(kwargs)
        self._handle_autoscaling_options(kwargs)
        with halo.Halo(text="Creating new deployment", spinner="dots"):
            deployment_id = self.client.create(**kwargs)

        self.logger.log("New deployment created with id: {}".format(deployment_id))
        self.logger.log(self.get_instance_url(deployment_id))
Esempio n. 6
0
    def execute(self, json_):
        workspace_url = self._workspace_handler.handle(json_)
        if workspace_url:
            json_['workspaceUrl'] = workspace_url

        with halo.Halo(text="Creating new experiment", spinner="dots"):
            response = self.api.post("/experiments/", json=json_)

        self._log_create_experiment(
            response, "New experiment created with ID: {}",
            "Unknown error while creating the experiment")
Esempio n. 7
0
 def execute(self, job_id, destination_directory):
     artifact_downloader = JobArtifactsDownloader(
         self.api_key,
         logger=self.logger,
         ps_client_name=cli_constants.CLI_PS_CLIENT_NAME,
     )
     with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE, spinner="dots"):
         try:
             artifact_downloader.download(job_id, destination_directory)
         except OSError as e:
             raise sdk_exceptions.GradientSdkError(e)
Esempio n. 8
0
    def execute(self, json_):
        json_, data = self._handle_workspace(json_)

        with halo.Halo(text=self.SPINNER_MESSAGE, spinner="dots"):
            try:
                job_id = self._create(json_, data)
            except api_sdk.GradientSdkError as e:
                self.logger.error(e)
                return

            self.logger.log(
                self.CREATE_SUCCESS_MESSAGE_TEMPLATE.format(job_id))
Esempio n. 9
0
    def _get_instances(self, kwargs):
        limit = kwargs.get('limit') or 20
        offset = 0

        while True:
            with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE, spinner="dots"):
                results = self.client.list(limit=limit + 1, offset=offset, **kwargs)
            has_more = len(results) > limit
            yield results[:limit], has_more
            if not has_more:
                break
            offset += limit
Esempio n. 10
0
    def execute(self, **kwargs):
        with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE, spinner="dots"):
            response = self._get_response(kwargs)

        try:
            if not response.ok:
                self.logger.log_error_response(response.json())
                return

            objects = self._get_objects(response, kwargs)
        except (ValueError, KeyError) as e:
            self.logger.error("Error while parsing response data: {}".format(e))
        else:
            self._log_objects_list(objects)
Esempio n. 11
0
    def execute(self, json_):
        if "ignore_files" in json_:
            json_["ignore_files"] = self._parse_comma_separated_to_list(json_["ignore_files"])

        self._handle_workspace(json_)

        with halo.Halo(text=self.SPINNER_MESSAGE, spinner="dots"):
            try:
                experiment_id = self._create(json_)
            except api_sdk.GradientSdkError as e:
                self.logger.error(e)
                return

        self.logger.log(self.CREATE_SUCCESS_MESSAGE_TEMPLATE.format(experiment_id))
Esempio n. 12
0
    def execute(self, json_, add_to_tensorboard=False):
        self._handle_workspace(json_)
        self._handle_dataset_data(json_)

        with halo.Halo(text=self.SPINNER_MESSAGE, spinner="dots"):
            experiment_id = self._create(json_)

        self.logger.log(
            self.CREATE_SUCCESS_MESSAGE_TEMPLATE.format(experiment_id))
        self.logger.log(
            self.get_instance_url(experiment_id, json_["project_id"]))

        self._maybe_add_to_tensorboard(add_to_tensorboard, experiment_id,
                                       self.api_key)
        return experiment_id
Esempio n. 13
0
    def execute(self, **kwargs):
        with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE, spinner="dots"):
            try:
                start_after = None
                instances = []
                while True:
                    pagination_response = self.client.artifacts_list(
                        start_after=start_after, **kwargs)

                    if pagination_response.data:
                        instances.extend(pagination_response.data)
                    start_after = pagination_response.start_after

                    if start_after is None:
                        break
            except sdk_exceptions.GradientSdkError as e:
                raise exceptions.ReceivingDataFailedError(e)

        self._log_objects_list(instances, kwargs)
Esempio n. 14
0
    def _generate_data_table(self, **kwargs):
        limit = kwargs.get("limit")
        offset = kwargs.get("offset")
        next_iteration = True

        while next_iteration:
            with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE,
                           spinner="dots"):
                kwargs["offset"] = offset
                instances = self._get_instances(**kwargs)
            if instances:
                table_data = self._get_table_data(instances)
                table_str = self._make_list_table(table_data) + "\n"
            else:
                table_str = "No data found"

            if len(instances) < limit:
                next_iteration = False

            yield table_str, next_iteration
            offset += limit
Esempio n. 15
0
    def _generate_data_table(self, **kwargs):
        limit = kwargs.get("limit")
        offset = kwargs.get("offset")
        meta_data = dict()
        while self.TOTAL_ITEMS_KEY not in meta_data or offset < meta_data.get(
                self.TOTAL_ITEMS_KEY):
            with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE,
                           spinner="dots"):
                kwargs["offset"] = offset
                instances, meta_data = self._get_instances(**kwargs)
            next_iteration = False
            if instances:
                table_data = self._get_table_data(instances)
                table_str = self._make_list_table(table_data) + "\n"
                if offset + limit < meta_data.get(self.TOTAL_ITEMS_KEY):
                    next_iteration = True
            else:
                table_str = "No data found"

            yield table_str, next_iteration
            offset += limit
Esempio n. 16
0
    def execute(self, id_):
        with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE, spinner="dots"):
            instance = self._get_instance(id_)

        self._log_object(instance)
Esempio n. 17
0
    def execute(self, **kwargs):
        with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE, spinner="dots"):
            instances = self._get_instances(**kwargs)

        self._log_objects_list(instances)
Esempio n. 18
0
    def execute(self, workflow_id, run):
        with halo.Halo(text=self.WAITING_FOR_RESPONSE_MESSAGE, spinner="dots"):
            instance = self.get_instance(workflow_id=workflow_id, run=run)

        self._log_object(instance)