diff --git a/qiskit_ibm/api/clients/runtime.py b/qiskit_ibm/api/clients/runtime.py index 4156c4999..05b8264d0 100644 --- a/qiskit_ibm/api/clients/runtime.py +++ b/qiskit_ibm/api/clients/runtime.py @@ -54,7 +54,6 @@ def program_create( description: str, max_execution_time: int, is_public: Optional[bool] = False, - version: Optional[str] = None, backend_requirements: Optional[Dict] = None, parameters: Optional[Dict] = None, return_values: Optional[List] = None, @@ -68,7 +67,6 @@ def program_create( description: Program description. max_execution_time: Maximum execution time. is_public: Whether the program should be public. - version: Program version. backend_requirements: Backend requirements. parameters: Program parameters. return_values: Program return values. @@ -81,7 +79,7 @@ def program_create( program_data=program_data, name=name, description=description, max_execution_time=max_execution_time, - is_public=is_public, version=version, backend_requirements=backend_requirements, + is_public=is_public, backend_requirements=backend_requirements, parameters=parameters, return_values=return_values, interim_results=interim_results ) diff --git a/qiskit_ibm/api/rest/runtime.py b/qiskit_ibm/api/rest/runtime.py index e8252ee0b..da8cf3487 100644 --- a/qiskit_ibm/api/rest/runtime.py +++ b/qiskit_ibm/api/rest/runtime.py @@ -70,7 +70,6 @@ def create_program( description: str, max_execution_time: int, is_public: Optional[bool] = False, - version: Optional[str] = None, backend_requirements: Optional[Dict] = None, parameters: Optional[Dict] = None, return_values: Optional[List] = None, @@ -84,7 +83,6 @@ def create_program( description: Program description. max_execution_time: Maximum execution time. is_public: Whether the program should be public. - version: Program version. backend_requirements: Backend requirements. parameters: Program parameters. return_values: Program return values. @@ -99,8 +97,6 @@ def create_program( 'description': description.encode(), 'max_execution_time': max_execution_time, 'isPublic': is_public} - if version is not None: - data['version'] = version if backend_requirements: data['backendRequirements'] = json.dumps(backend_requirements) if parameters: diff --git a/qiskit_ibm/runtime/__init__.py b/qiskit_ibm/runtime/__init__.py index 83012f6e2..7b8fc84aa 100644 --- a/qiskit_ibm/runtime/__init__.py +++ b/qiskit_ibm/runtime/__init__.py @@ -191,14 +191,11 @@ def interim_result_callback(job_id, interim_result): provider = IBMProvider() program_id = provider.runtime.upload_program( data="my_vqe.py", - metadata="my_vqe_metadata.json", - version="1.2" + metadata="my_vqe_metadata.json" ) In the example above, the file ``my_vqe.py`` contains the program data, and -``my_vqe_metadata.json`` contains the program metadata. An additional -parameter ``version`` is also specified, which takes precedence over any -``version`` value specified in ``my_vqe_metadata.json``. +``my_vqe_metadata.json`` contains the program metadata. Method :meth:`IBMRuntimeService.delete_program` allows you to delete a program. diff --git a/qiskit_ibm/runtime/ibm_runtime_service.py b/qiskit_ibm/runtime/ibm_runtime_service.py index 5d10f1d0e..febe967f6 100644 --- a/qiskit_ibm/runtime/ibm_runtime_service.py +++ b/qiskit_ibm/runtime/ibm_runtime_service.py @@ -195,7 +195,6 @@ def _to_program(self, response: Dict) -> RuntimeProgram: interim_results=interim_results, max_execution_time=response.get('cost', 0), creation_date=response.get('creationDate', ""), - version=response.get('version', "0"), backend_requirements=backend_req, is_public=response.get('isPublic', False)) @@ -272,7 +271,6 @@ def upload_program( is_public: Optional[bool] = False, max_execution_time: Optional[int] = None, description: Optional[str] = None, - version: Optional[float] = None, backend_requirements: Optional[str] = None, parameters: Optional[List[ProgramParameter]] = None, return_values: Optional[List[ProgramResult]] = None, @@ -306,7 +304,6 @@ def upload_program( not specified via `metadata`. is_public: Whether the runtime program should be visible to the public. description: Program description. Required if not specified via `metadata`. - version: Program version. The default is 1.0 if not specified. backend_requirements: Backend requirements. parameters: A list of program input parameters. return_values: A list of program return values. @@ -326,7 +323,7 @@ def upload_program( metadata=metadata, name=name, max_execution_time=max_execution_time, is_public=is_public, description=description, - version=version, backend_requirements=backend_requirements, + backend_requirements=backend_requirements, parameters=parameters, return_values=return_values, interim_results=interim_results) @@ -385,7 +382,7 @@ def _merge_metadata( initial[key] = val # TODO validate metadata format - metadata_keys = ['name', 'max_execution_time', 'description', 'version', + metadata_keys = ['name', 'max_execution_time', 'description', 'backend_requirements', 'parameters', 'return_values', 'interim_results', 'is_public'] return {key: val for key, val in initial.items() if key in metadata_keys} diff --git a/qiskit_ibm/runtime/program/program_metadata_sample.json b/qiskit_ibm/runtime/program/program_metadata_sample.json index a38c18fd6..5df24385f 100644 --- a/qiskit_ibm/runtime/program/program_metadata_sample.json +++ b/qiskit_ibm/runtime/program/program_metadata_sample.json @@ -2,7 +2,6 @@ "name": "runtime-simple", "description": "Simple runtime program used for testing.", "max_execution_time": 300, - "version": 1.0, "backend_requirements": {"min_num_qubits": 5}, "parameters": [ {"name": "iterations", "description": "Number of iterations to run. Each iteration generates a runs a random circuit.", "type": "integer", "required": true} diff --git a/qiskit_ibm/runtime/runtime_program.py b/qiskit_ibm/runtime/runtime_program.py index ee884146b..bdb503d46 100644 --- a/qiskit_ibm/runtime/runtime_program.py +++ b/qiskit_ibm/runtime/runtime_program.py @@ -51,7 +51,6 @@ def __init__( return_values: Optional[List] = None, interim_results: Optional[List] = None, max_execution_time: int = 0, - version: str = "0", backend_requirements: Optional[Dict] = None, creation_date: str = "", is_public: Optional[bool] = False @@ -66,7 +65,6 @@ def __init__( return_values: Documentation on program return values. interim_results: Documentation on program interim results. max_execution_time: Maximum execution time. - version: Program version. backend_requirements: Backend requirements. creation_date: Program creation date. is_public: ``True`` if program is visible to all. ``False`` if it's only visible to you. @@ -75,7 +73,6 @@ def __init__( self._id = program_id self._description = description self._max_execution_time = max_execution_time - self._version = version self._backend_requirements = backend_requirements or {} self._parameters: List[ProgramParameter] = [] self._return_values: List[ProgramResult] = [] @@ -114,7 +111,6 @@ def _format_common(items: List) -> None: formatted = [f'{self.program_id}:', f" Name: {self.name}", f" Description: {self.description}", - f" Version: {self.version}", f" Creation date: {self.creation_date}", f" Max execution time: {self.max_execution_time}", f" Input parameters:"] @@ -148,7 +144,6 @@ def to_dict(self) -> Dict: "name": self.name, "description": self.description, "max_execution_time": self.max_execution_time, - "version": self.version, "backend_requirements": self.backend_requirements, "parameters": self.parameters(), "return_values": self.return_values, @@ -227,15 +222,6 @@ def max_execution_time(self) -> int: """ return self._max_execution_time - @property - def version(self) -> str: - """Program version. - - Returns: - Program version. - """ - return self._version - @property def backend_requirements(self) -> Dict: """Backend requirements. diff --git a/releasenotes/notes/remove-version-field-0543061d4a7e059a.yaml b/releasenotes/notes/remove-version-field-0543061d4a7e059a.yaml new file mode 100644 index 000000000..099dcd222 --- /dev/null +++ b/releasenotes/notes/remove-version-field-0543061d4a7e059a.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - | + Runtime programs will no longer have a ``version`` field. diff --git a/test/ibm/runtime/fake_runtime_client.py b/test/ibm/runtime/fake_runtime_client.py index 6711d5ee7..a041c718a 100644 --- a/test/ibm/runtime/fake_runtime_client.py +++ b/test/ibm/runtime/fake_runtime_client.py @@ -26,7 +26,7 @@ class BaseFakeProgram: """Base class for faking a program.""" - def __init__(self, program_id, name, data, cost, description, version="1.0", + def __init__(self, program_id, name, data, cost, description, backend_requirements=None, parameters=None, return_values=None, interim_results=None, is_public=False): """Initialize a fake program.""" @@ -35,7 +35,6 @@ def __init__(self, program_id, name, data, cost, description, version="1.0", self._data = data self._cost = cost self._description = description - self._version = version self._backend_requirements = backend_requirements self._parameters = parameters self._return_values = return_values @@ -48,7 +47,6 @@ def to_dict(self, include_data=False): 'name': self._name, 'cost': self._cost, 'description': self._description, - 'version': self._version, 'isPublic': self._is_public} if include_data: out['data'] = self._data @@ -237,7 +235,7 @@ def list_programs(self): programs.append(prog.to_dict()) return programs - def program_create(self, program_data, name, description, max_execution_time, version="1.0", + def program_create(self, program_data, name, description, max_execution_time, backend_requirements=None, parameters=None, return_values=None, interim_results=None, is_public=False): """Create a program.""" @@ -249,7 +247,7 @@ def program_create(self, program_data, name, description, max_execution_time, ve raise RequestsApiError("Program already exists.", status_code=409) self._programs[program_id] = BaseFakeProgram( program_id=program_id, name=name, data=program_data, cost=max_execution_time, - description=description, version=version, backend_requirements=backend_requirements, + description=description, backend_requirements=backend_requirements, parameters=parameters, return_values=return_values, interim_results=interim_results, is_public=is_public) return {'id': program_id} diff --git a/test/ibm/runtime/test_runtime.py b/test/ibm/runtime/test_runtime.py index f60f027fb..b918eab08 100644 --- a/test/ibm/runtime/test_runtime.py +++ b/test/ibm/runtime/test_runtime.py @@ -70,7 +70,6 @@ class TestRuntime(IBMTestCase): "name": "qiskit-test", "description": "Test program.", "max_execution_time": 300, - "version": "0.1", "backend_requirements": {"min_num_qubits": 5}, "parameters": [ {'name': 'param1', 'description': 'Desc 1', 'type': 'str', 'required': True}, @@ -286,13 +285,13 @@ def test_print_programs(self): for prog in programs: self.assertIn(prog.program_id, stdout) self.assertIn(prog.name, stdout) - self.assertNotIn(prog.version, stdout) + self.assertNotIn(str(prog.max_execution_time), stdout) self.runtime.pprint_programs(detailed=True) stdout_detailed = mock_stdout.getvalue() for prog in programs: self.assertIn(prog.program_id, stdout_detailed) self.assertIn(prog.name, stdout_detailed) - self.assertIn(prog.version, stdout_detailed) + self.assertIn(str(prog.max_execution_time), stdout_detailed) def test_upload_program(self): """Test uploading a program.""" @@ -600,7 +599,6 @@ def test_program_metadata(self): self.assertEqual(self.DEFAULT_METADATA['description'], program.description) self.assertEqual(self.DEFAULT_METADATA['max_execution_time'], program.max_execution_time) - self.assertEqual(self.DEFAULT_METADATA["version"], program.version) self.assertEqual(self.DEFAULT_METADATA['backend_requirements'], program.backend_requirements) self.assertEqual([ProgramParameter(**param) for param in @@ -615,12 +613,11 @@ def test_program_metadata(self): def test_metadata_combined(self): """Test combining metadata""" - update_metadata = {"version": "1.2", "max_execution_time": 600} + update_metadata = {"max_execution_time": 600} program_id = self.runtime.upload_program( data="def main() {}", metadata=self.DEFAULT_METADATA, **update_metadata) program = self.runtime.program(program_id) self.assertEqual(update_metadata['max_execution_time'], program.max_execution_time) - self.assertEqual(update_metadata["version"], program.version) def test_different_providers(self): """Test retrieving job submitted with different provider.""" diff --git a/test/ibm/runtime/test_runtime_integration.py b/test/ibm/runtime/test_runtime_integration.py index de8559e23..b08f4f059 100644 --- a/test/ibm/runtime/test_runtime_integration.py +++ b/test/ibm/runtime/test_runtime_integration.py @@ -613,7 +613,6 @@ def _validate_program(self, program): self.assertTrue(program.description) self.assertTrue(program.max_execution_time) self.assertTrue(program.creation_date) - self.assertTrue(program.version) def _upload_program( self,