Example #1
0
    def experiment_create(
            self,
            input_: BasicTraining,
            name: str,
            device: str = 'gpu'
    ) -> CloudExperiment:
        """Create a new experiment, queuing its execution.

        Args:
            input_: the experiment to be executed.
            name: the name of the experiment.
            device: the desired device.

        Returns:
            A ``CloudExperiment``.
        """
        # Prepare the API data.
        payload = self.converter.to_proto(input_).SerializeToString()

        # Create the experiment.
        response = self.experiments.post({'name': name,
                                          'category': 'train'})
        experiment = ExperimentParser.parse_experiment(response, self)

        # Create the input.
        response = self.inputs.post({'experiment': experiment.id_,
                                     'device': device})
        object_storage_url = response['url']
        _ = self.object_storage_session.put(url=object_storage_url, data=payload)

        # Create the job.
        response = self.jobs.post({'experiment': experiment.id_})
        experiment.job = ExperimentParser.parse_job(response)

        return experiment
Example #2
0
    def experiments_list(self) -> List[CloudExperiment]:
        """Return a list of experiments."""
        response = self.experiments.list()

        return [
            ExperimentParser.parse_experiment(experiment, self)
            for experiment in response
        ]
Example #3
0
    def job_get(self, job_id: str) -> CloudJob:
        """Get an existing job by id.

        Args:
            job_id: id of the job.

        Returns:
            A `CloudJob` with the specified id.
        """
        response = self.jobs.get(job_id)

        return ExperimentParser.parse_job(response)
Example #4
0
    def experiment_get(self, experiment_id: str) -> CloudExperiment:
        """Get an existing job by id.

        Args:
            experiment_id: id of the experiment.

        Returns:
            A `CloudExperiment` with the specified id.
        """
        response = self.experiments.get(experiment_id)

        return ExperimentParser.parse_experiment(response, self)