Exemple #1
0
    def submit(self, problem: Union[str, Problem]) -> Job:
        """Submits a job to execution to the associated Azure Quantum Workspace.

       :param problem: 
            The Problem to solve. It can be an instance of a Problem, 
            or the URL of an Azure Storage Blob where the serialized version
            of a Problem has been uploaded.
        """
        ## Create a container URL:
        job_id = Job.create_job_id()
        logger.info(f"Submitting job with id: {job_id}")

        container_name = f"job-{job_id}"

        if not self.workspace.storage:
            # No storage account is passed, in this case, get linked account from the service
            container_uri = self.workspace._get_linked_storage_sas_uri(
                container_name)
            container_client = ContainerClient.from_container_url(
                container_uri)
            create_container_using_client(container_client)
            container_uri = azure.quantum.storage.remove_sas_token(
                container_uri)
        else:
            # Storage account is passed, use it to generate a container_uri
            container_uri = azure.quantum.storage.get_container_uri(
                self.workspace.storage, container_name)

        logger.debug(f"Container URI: {container_uri}")

        if isinstance(problem, str):
            name = "Optimization problem"
            problem_uri = problem
        else:
            name = problem.name
            problem_uri = problem.upload(self.workspace,
                                         compress=True,
                                         container_name=container_name,
                                         blob_name="inputData")

        logger.info(
            f"Submitting problem '{name}'. Using payload from: '{problem_uri}'"
        )

        details = JobDetails(id=job_id,
                             name=name,
                             container_uri=container_uri,
                             input_data_format=self.input_data_format,
                             output_data_format=self.output_data_format,
                             input_data_uri=problem_uri,
                             provider_id=self.provider,
                             target=self.target,
                             input_params=self.params)

        logger.debug(f"==> submitting: {details}")
        job = self.workspace.submit_job(Job(self.workspace, details))
        return job
Exemple #2
0
 def get_test_job_id(self):
     return ZERO_UID if self.is_playback \
            else Job.create_job_id()
Exemple #3
0
    def get_dummy_job_id(self):
        if self.in_recording or self.is_live:
            return Job.create_job_id()

        return self.dummy_uid