Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions qiskit_ibm_runtime/runtime_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ def _format_common(schema: Dict) -> None:
+ str(property_name in schema.get("required", []))
)

def _format_backend_requirements(schema: Dict) -> None:
"""Add backend requirements details to `formatted`."""
if "input_allowed" in schema:
formatted.append(
" " * 4 + "Input allowed: {}".format(str(schema["input_allowed"]))
)
if "min_num_qubits" in schema:
formatted.append(
" " * 4
+ "Minimum number qubits: {}".format(str(schema["min_num_qubits"]))
Comment thread
kt474 marked this conversation as resolved.
Outdated
)
if "supported_features" in schema:
formatted.append(
" " * 4
+ "Supported features: {}".format(str(schema["supported_features"]))
)
Comment thread
kt474 marked this conversation as resolved.
for key, value in schema.items():
if key not in ["input_allowed", "min_num_qubits", "supported_features"]:
formatted.append(
" " * 4 + "{}: {}".format(sentence_case(key), str(value))
)

Comment thread
rathishcholarajan marked this conversation as resolved.
def sentence_case(camel_case_text: str) -> str:
"""Converts camelCase to Sentence case"""
if camel_case_text == "":
Expand All @@ -131,6 +153,12 @@ def sentence_case(camel_case_text: str) -> str:
f" Max execution time: {self.max_execution_time}",
]

formatted.append(" Backend requirements:")
if self._backend_requirements:
_format_backend_requirements(self._backend_requirements)
else:
formatted.append(" " * 4 + "none")

formatted.append(" Input parameters:")
if self._parameters:
_format_common(self._parameters)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
upgrade:
- |
When printing programs with :meth:`qiskit_ibm_runtime.IBMRuntimeService.pprint_programs`,
``backend_requirements`` will now be listed.

2 changes: 2 additions & 0 deletions test/test_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ def test_print_programs(self, service):
self.assertIn(prog.program_id, stdout)
self.assertIn(prog.name, stdout)
self.assertNotIn(str(prog.max_execution_time), stdout)
self.assertNotIn("Backend requirements", stdout)
service.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(str(prog.max_execution_time), stdout_detailed)
self.assertIn("Backend requirements", stdout_detailed)

@run_legacy_and_cloud_fake
def test_upload_program(self, service):
Expand Down