Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Remove version field from runtime program (#152)
Browse files Browse the repository at this point in the history
* Remove version field from runtime program

* Add release note
  • Loading branch information
rathishcholarajan authored Oct 18, 2021
1 parent 8a1921f commit 464192f
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 44 deletions.
4 changes: 1 addition & 3 deletions qiskit_ibm/api/clients/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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
)
Expand Down
4 changes: 0 additions & 4 deletions qiskit_ibm/api/rest/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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:
Expand Down
7 changes: 2 additions & 5 deletions qiskit_ibm/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 2 additions & 5 deletions qiskit_ibm/runtime/ibm_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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)

Expand Down Expand Up @@ -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}
Expand Down
1 change: 0 additions & 1 deletion qiskit_ibm/runtime/program/program_metadata_sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
14 changes: 0 additions & 14 deletions qiskit_ibm/runtime/runtime_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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] = []
Expand Down Expand Up @@ -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:"]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/remove-version-field-0543061d4a7e059a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
upgrade:
- |
Runtime programs will no longer have a ``version`` field.
8 changes: 3 additions & 5 deletions test/ibm/runtime/fake_runtime_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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."""
Expand All @@ -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}
Expand Down
9 changes: 3 additions & 6 deletions test/ibm/runtime/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand All @@ -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."""
Expand Down
1 change: 0 additions & 1 deletion test/ibm/runtime/test_runtime_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 464192f

Please sign in to comment.