Skip to content

Commit 4e0ef34

Browse files
committed
added a sleep command to simulate a job running for real and updated readme
1 parent a136bda commit 4e0ef34

2 files changed

Lines changed: 6 additions & 82 deletions

File tree

README.md

Lines changed: 3 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,5 @@
1-
# Quantum Server Plugin
1+
# Fake Plugin
22

3+
This is a fake plugin for testing qserver.
34

4-
![Build, Test and publish](https://github.com/quantum-plugins/quantum-server-plugin-template/actions/workflows/build_test_publish.yml/badge.svg)
5-
![release version](https://github.com/quantum-plugins/quantum-server-plugin-template/actions/workflows/release.yml/badge.svg)
6-
7-
To create a plugin for [local-quantum-server](https://github.com/Dpbm/local-quantum-server), `start by using this template` and then follow the steps below.
8-
9-
## Setup your plugin
10-
11-
1. Setup your `requirements.txt`
12-
13-
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](./requirements.txt), line by line.
14-
15-
2. Create a virtual environment
16-
17-
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.
18-
19-
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.
20-
21-
3. Add your code
22-
23-
After that, update the folder [example_plugin](./example_plugin/) to your plugin's name and start adding your code.
24-
25-
`Note: Make sure your folder name is the same as the plugin's name on setup.py.`
26-
27-
Inside [example_plugin](./example_plugin/) directory, you'll find some files:
28-
29-
- [interface.py](./example_plugin/interface.py): that's the file that creates the abstract class `Plugin`, which your project must use to ensure the correct usability.
30-
Don't change this file. Only `import` the `types`, `classes` and `functions` you need.
31-
- [plugin.py](./example_plugin/plugin.py): that's the plugin starting point. In it, you need to add some logic to handle the user input inside the `execute` method. 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.
32-
- [backends.txt](./example_plugin/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.
33-
- [config.py](./example_plugin/config.py): that's the python file that keeps all the plugin configs. Please, don't change it.
34-
35-
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](./setup.py) or [pyproject.toml](./pyproject.toml).
36-
37-
Also, you need to ensure the correct handling of the `result_types`, the possible inputs are: `'quasi_dist', 'counts', 'expval'` for now. `counts` and `quasi_dists` must return a `dict` and `expval` a `list of float`.
38-
39-
4. Add tests
40-
41-
Inside [tests directory](./tests/) add your tests using pytest. Although it's not mandatory, it's a nice practice to make your project easier to manipulate.
42-
43-
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:
44-
45-
```bash
46-
pip install -r dev-requirements.txt
47-
tox
48-
```
49-
50-
5. Update the [setup.py](./setup.py)
51-
52-
With your code done, start adding your info to [setup.py](./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](https://setuptools.pypa.io/en/latest/index.html).
53-
54-
Also, take a look into [Manifest.in](./MANIFEST.in) and change the required lines.
55-
56-
6. Update the [LICENSE](./LICENSE)
57-
58-
The License for plugins is always `MIT`. So before proceeding, remember to update the [LICENSE file](./LICENSE) adding the year and your name.
59-
60-
6. Update the [README.md file](./README.md)
61-
62-
Doing that, delete everything in this very `README.md` file and describe your project.
63-
64-
7. Update GH Actions workflow
65-
66-
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.
67-
68-
So, to do that, go to [.github/workflows/build_test_publish.yml](./.github/workflows/build_test_publish.yml) and them ensure to update what's being required inside.
69-
70-
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](https://pypi.org/) and setup a [Trusted publisher](https://docs.pypi.org/trusted-publishers/) mapping to your github workflow.
71-
72-
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](./.github/workflows/build_test_publish.yml) workflow.
73-
74-
8. Request your plugin to be added to the list
75-
76-
After that, open an issue on [github.com/quantum-plugins/plugins-list](https://github.com/quantum-plugins/plugins-list) requesting your plugin to be added on the official plugins list.
77-
78-
As soon as possible we'll see that and procede with the addition and your plugins will be called official 😊
79-
80-
## CONGRATS!!!
81-
82-
Now, you have a quantum plugin!!!!
83-
84-
Thank you so much for joining this amazing community🎉🎉🎉
5+
It's not meant to be used for real applications, just to ease the process of testing parts.

fake_plugin/plugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from time import sleep
23
from .interface import (
34
PluginInterface,
45
Backend,
@@ -49,5 +50,7 @@ def execute(
4950

5051
if result_type == "expval":
5152
assert metadata.get("obs") is not None, "Invalid observables"
53+
54+
sleep(10) # simulate a job running
5255

5356
return data_for_returning[result_type] # type: ignore

0 commit comments

Comments
 (0)