A simple quantum plugin
Project description
Quantum Server Plugin
To create a plugin for local-quantum-server, start by using this template and then follow the steps below.
Setup your plugin
- Setup your
requirements.txt
In your plugin, you'll probably need some external dependencies, like qiskit, cirq, pennylane, numpy, etc. List every required dependency inside the requirements.txt file, line by line.
- Create a virtual environment
To keep your work clean, make sure to use a virtual environment, this way your work won't get conflicted with pre-installed system dependencies.
Also, using environment managers allows you to easily change python versions. By default I'm using the python 3.12.8, however it maybe not the perfect match for your plugin. So remember to change it and explicit it on your project.
- Add your code
After that, update the folder example_plugin to your plugin's name and start adding your code.
Note: Make sure your folder name is the same as the plugin's name on setup.py.
Inside example_plugin directory, you'll find some files:
- interface.py: that's the file that creates the abstract class
Plugin, which your project must use to ensure the correct usability. Don't change this file. Onlyimportthetypes,classesandfunctionsyou need. - plugin.py: that's the plugin starting point. In it, you need to add some logic to handle the user input inside the
executemethod. By default, the class uses some decorators to ensure that only correct values are passed (backend name, result type and qasm file (check if it exists)). However, you're free to implement your logic and do further checks. - backends.txt: this file, is responsible to store the list of backends your plugin support. Make sure to clean that and add the names line by line. Don't delete this file.
- config.py: that's the python file that keeps all the plugin configs. Please, don't change it.
Besides that, you're allowed to add new files and create your structure. But, keep in mind that, more complex projects may need additional configurations on either setup.py or pyproject.toml.
Also, you need to ensure the correct handling of the result_types, the possible inputs are: 'quasi_dist', 'counts', 'expval' for now.
- Add tests
Inside tests directory add your tests using pytest. Although it's not mandatory, it's a nice practice to make your project easier to manipulate.
By default, tox is configured to run lint and type checks, as well as code tests. so remember to install the dev-dependencies and run tox:
pip install -r dev-requirements.txt
tox
- Update the setup.py
With your code done, start adding your info to setup.py. If you have a more complex structure, you may need to add more configurations to that, so remember to check the setuptools guide.
- Update the LICENSE
The License for plugins is always MIT. So before proceeding, remember to update the LICENSE file adding the year and your name.
- Update the README.md file
Doing that, delete everything in this very README.md file and describe your project.
- Update GH Actions workflow
To be an accepted plugin, your must have your code on github. Due to that, it's possible to run some CI workflows to ensure you're code is correct and ready to be distributed.
So, to do that, go to .github/workflows/build_test_publish.yml and them ensure to update what's being required inside.
For plugins, every time it's pushed to the main branch, the code is built, tested and them published to PYPI automatically. To ensure that everything is going to go well, create and account at pypi.org and setup a Trusted publisher mapping to your github workflow.
It's not mandatory publishing it to PYPI, but it's a nice way to share it abroad. If you don't want this part, remove the publish job from .github/workflows/build_test_publish.yml workflow.
- Request your plugin to be added to the list
After that, open an issue on github.com/quantum-plugins/plugins-list requesting your plugin to be added on the official plugins list.
As soon as possible we'll see that and procede with the addition and your plugins will be called official 😊
CONGRATS!!!
Now, you have a quantum plugin!!!!
Thank you so much for joining this amazing community🎉🎉🎉
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file example_plugin-1.0.2.tar.gz.
File metadata
- Download URL: example_plugin-1.0.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13b06189a31f75fb006502789254bf8ee71338174ed7310d61d582bdbd44e584
|
|
| MD5 |
22f84e8e59818e069b9b41fa9ec6d1d7
|
|
| BLAKE2b-256 |
60becc43bddf7b663af50a587f3f391adcb9b10bb970e1031d8231c72f36ff07
|
Provenance
The following attestation bundles were made for example_plugin-1.0.2.tar.gz:
Publisher:
build_test_publish.yml on quantum-plugins/quantum-server-plugin-template
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
example_plugin-1.0.2.tar.gz -
Subject digest:
13b06189a31f75fb006502789254bf8ee71338174ed7310d61d582bdbd44e584 - Sigstore transparency entry: 171686191
- Sigstore integration time:
-
Permalink:
quantum-plugins/quantum-server-plugin-template@ce055eb89f9a4c43cd706f3ea2a145026062d76f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/quantum-plugins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_test_publish.yml@ce055eb89f9a4c43cd706f3ea2a145026062d76f -
Trigger Event:
push
-
Statement type:
File details
Details for the file example_plugin-1.0.2-py3-none-any.whl.
File metadata
- Download URL: example_plugin-1.0.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22e1708af7b945c800516956565f6fa899bd9f2d7a08114205e03e89baf8a0bd
|
|
| MD5 |
0594ab5f8ea3d074b6d40be327403dcf
|
|
| BLAKE2b-256 |
940eda4f513f27ecbf7a4e91b3431eaf394584dee80de9c6c5039c10ab427256
|
Provenance
The following attestation bundles were made for example_plugin-1.0.2-py3-none-any.whl:
Publisher:
build_test_publish.yml on quantum-plugins/quantum-server-plugin-template
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
example_plugin-1.0.2-py3-none-any.whl -
Subject digest:
22e1708af7b945c800516956565f6fa899bd9f2d7a08114205e03e89baf8a0bd - Sigstore transparency entry: 171686192
- Sigstore integration time:
-
Permalink:
quantum-plugins/quantum-server-plugin-template@ce055eb89f9a4c43cd706f3ea2a145026062d76f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/quantum-plugins
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_test_publish.yml@ce055eb89f9a4c43cd706f3ea2a145026062d76f -
Trigger Event:
push
-
Statement type: