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

Accept JSON schema as program metadata#158

Merged
rathishcholarajan merged 4 commits intoQiskit:runtime-release-q4from
rathishcholarajan:44-json-schema
Oct 25, 2021
Merged

Accept JSON schema as program metadata#158
rathishcholarajan merged 4 commits intoQiskit:runtime-release-q4from
rathishcholarajan:44-json-schema

Conversation

@rathishcholarajan
Copy link
Copy Markdown
Member

Summary

Accept JSON schema as program metadata and print it in human readable format in pprint_programs().

Details and comments

Fixes #44

@rathishcholarajan rathishcholarajan self-assigned this Oct 15, 2021
@rathishcholarajan rathishcholarajan added the Changelog: API Change Include in the Changed section of the changelog label Oct 15, 2021
Copy link
Copy Markdown
Collaborator

@jyu00 jyu00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the new metadata format you're basing this on is correct, unless of course the API doc is wrong lol

Comment thread qiskit_ibm/runtime/runtime_program.py
Comment thread test/ibm/runtime/test_runtime.py Outdated
Copy link
Copy Markdown
Collaborator

@jyu00 jyu00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show what the output of print(program) would look like for say sample-program with this new code? Using this input

{
  "name": "sample-program",
  "description": "A sample runtime program.",
  "max_execution_time": 300,
  "spec": {
    "backend_requirements": {
      "min_num_qubits": 5
    },
    "parameters": {
      "$schema": "https://json-schema.org/draft/2019-09/schema",
      "properties": {
        "iterations": {
          "type": "integer",
          "minimum": 0,
          "description": "Number of iterations to run. Each iteration generates a runs a random circuit."
        }
      },
      "required": [
        "iterations"
      ]
    },
    "return_values": {
      "$schema": "https://json-schema.org/draft/2019-09/schema",
      "description": "A string that says 'All done!'.",
      "type": "string"
    },
    "interim_results": {
      "$schema": "https://json-schema.org/draft/2019-09/schema",
      "properties": {
        "iteration": {
          "type": "integer",
          "description": "Iteration number."
        },
        "counts": {
          "description": "Histogram data of the circuit result.",
          "type": "object"
        }
      }
    }
  }
}

Comment thread qiskit_ibm/runtime/ibm_runtime_service.py Outdated
Comment thread qiskit_ibm/runtime/program/program_metadata_sample.json
@rathishcholarajan
Copy link
Copy Markdown
Member Author

Can you show what the output of print(program) would look like for say sample-program with this new code? Using this input

Output will look like this:

==================================================
sample-program:
  Name: sample-program
  Description: A sample runtime program.
  Creation date: 2021-05-10T08:59:51Z
  Update date: 2021-06-04T14:11:19Z
  Max execution time: 300
  Input parameters:
    Properties:
        - iterations:
            Type: integer
            Minimum: 0
            Description: Number of iterations to run. Each iteration generates a runs a random circuit.
            Required: True
  Interim results:
    Properties:
        - iteration:
            Type: integer
            Description: Iteration number.
            Required: False
        - counts:
            Description: Histogram data of the circuit result.
            Type: object
            Required: False
  Returns:
    Description: A string that says 'All done!'.
    Type: string

@rathishcholarajan rathishcholarajan added this to the 0.1 milestone Oct 19, 2021
Copy link
Copy Markdown
Collaborator

@jyu00 jyu00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments but mostly looks good!

Comment thread qiskit_ibm/runtime/ibm_runtime_service.py Outdated
Comment thread qiskit_ibm/runtime/ibm_runtime_service.py Outdated
Comment thread qiskit_ibm/runtime/program/program_metadata_sample.json Outdated
Comment thread releasenotes/notes/upgrade-metadata-json-schema-46f034ada7443cf9.yaml Outdated
Comment thread test/ibm/runtime/test_runtime.py Outdated
@rathishcholarajan rathishcholarajan changed the base branch from main to runtime-release-q4 October 21, 2021 18:30
Comment thread qiskit_ibm/runtime/ibm_runtime_service.py
Comment thread qiskit_ibm/runtime/program/program_metadata_sample.json Outdated
Comment thread test/ibm/runtime/test_runtime.py Outdated
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
Comment thread qiskit_ibm/runtime/program/program_metadata_sample.json Outdated
Comment thread qiskit_ibm/runtime/program/program_metadata_sample.json Outdated
Comment thread test/ibm/runtime/test_runtime.py Outdated
Copy link
Copy Markdown
Collaborator

@jyu00 jyu00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor doc changes but otherwise looks good!

Comment thread qiskit_ibm/runtime/ibm_runtime_service.py Outdated
Comment thread qiskit_ibm/runtime/program/program_metadata_sample.json Outdated
@jyu00 jyu00 added the backport potential The bug might be minimal and/or important enough to be port to stable label Oct 25, 2021
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
@rathishcholarajan rathishcholarajan merged commit a8fe605 into Qiskit:runtime-release-q4 Oct 25, 2021
rathishcholarajan added a commit that referenced this pull request Nov 2, 2021
* Accept JSON schema as program metadata

* Update qiskit_ibm/runtime/ibm_runtime_service.py

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
rathishcholarajan added a commit that referenced this pull request Nov 9, 2021
* Remove version field from runtime program (#152)

* Remove version field from runtime program

* Add release note

* Rename isPublic to is_public when creating or reading runtime programs (#155)

* Update programId to program_id when running program (#139)

This needs to change in the program upload body request in order to
meet the IBM Cloud API guidance.

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Add support to view program update date (#160)

* Upload runtime program using 'data' field (#157)

* Read programs from "programs" array in response (#161)

* Remove version field from runtime program (#152)

* Remove version field from runtime program

* Add release note

* Rename isPublic to is_public when creating or reading runtime programs (#155)

* Update programId to program_id when running program (#139)

This needs to change in the program upload body request in order to
meet the IBM Cloud API guidance.

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Add support to view program update date (#160)

* Upload runtime program using 'data' field (#157)

* Read programs from "programs" array in response (#161)

* Pass program as base64 string to update (#168)

* Accept JSON schema as program metadata (#158)

* Accept JSON schema as program metadata

* Update qiskit_ibm/runtime/ibm_runtime_service.py

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Pass program params as object (#171)

* Fix integration tests

* Use count to reduce one last extra call to API (#172)

* Allow updating runtime metadata in place (#188)

* update runtime metadata

* return if no data

* fix mypy

* Update releasenotes/notes/update-runtime-metadata-d2ddbcfc0d034530.yaml

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Remove version field from runtime program (#152)

* Remove version field from runtime program

* Add release note

* Rename isPublic to is_public when creating or reading runtime programs (#155)

* Update programId to program_id when running program (#139)

This needs to change in the program upload body request in order to
meet the IBM Cloud API guidance.

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Add support to view program update date (#160)

* Upload runtime program using 'data' field (#157)

* Read programs from "programs" array in response (#161)

* Pass program as base64 string to update (#168)

* Accept JSON schema as program metadata (#158)

* Accept JSON schema as program metadata

* Update qiskit_ibm/runtime/ibm_runtime_service.py

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Pass program params as object (#171)

* Fix integration tests

* Use count to reduce one last extra call to API (#172)

* Allow updating runtime metadata in place (#188)

* update runtime metadata

* return if no data

* fix mypy

* Update releasenotes/notes/update-runtime-metadata-d2ddbcfc0d034530.yaml

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Allow filtering runtime jobs by program ID (#193)

* Allow filtering runtime jobs by program ID

* Fix lint

* Allow runtime program authors to retrieve program data (#174)

* retrieve program data

* refetch once if no program data

* remove unused import

* refresh program on data property

* fix lint

* Update qiskit_ibm/runtime/runtime_program.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Update qiskit_ibm/runtime/runtime_program.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Update qiskit_ibm/runtime/runtime_program.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* add test case

* add test case

* add default data constant

* add _validate_program method

* Update test/ibm/runtime/test_runtime.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Update cache after updating program (#196)

* Allow filtering runtime jobs by provider (#197)

* add provider param

* split provider into hub/group/project

* add reno

* wip add test case

* fix lint/docs

* Update qiskit_ibm/runtime/ibm_runtime_service.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Update releasenotes/notes/filter-jobs-by-provider-dead04faaf223840.yaml

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* refactor test cases

* remove print

* add integration test

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Support pagination for retrieving runtime programs  (#170)

* wip add limit/offset params

* add reno

* refactor & update test case

* offset -> skip, implement refresh logic

* refresh when skip/limit not default

* Update releasenotes/notes/runtime-program-pagination-8d599ae984a5ce33.yaml

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Update releasenotes/notes/runtime-program-pagination-8d599ae984a5ce33.yaml

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* add  to test case

* refactor refresh logic

* refactor

* fix lint

* add integration test

* update doc string

* Update qiskit_ibm/api/clients/runtime.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* cleanup merge

* Apply suggestions from code review

* fix lint refactor

* Fetch all programs upfront 20 at a time and store in cache

For subsequent requests paginate and return from cache

* Fix integration test

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>
Co-authored-by: Rathish Cholarajan <Rathish.C@ibm.com>

Co-authored-by: Renier Morales <renier@users.noreply.github.com>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
Co-authored-by: Kevin Tian <kevin.tian@ibm.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport potential The bug might be minimal and/or important enough to be port to stable Changelog: API Change Include in the Changed section of the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accommodate and parse JSON schema as runtime program metadata

2 participants