Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client does not hang #42

Merged
merged 34 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f1a4812
flag to choose if client does not hang
marcorossi5 Jun 10, 2024
a25bcfa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 10, 2024
a0a6171
removing try except causing errors
marcorossi5 Jun 10, 2024
cc15a58
Merge remote-tracking branch 'origin/feature/client-does-not-hang' in…
marcorossi5 Jun 10, 2024
99a02ad
version warning raised only if local version is behind server version
marcorossi5 Jul 2, 2024
4894a5e
Merge branch 'main' into feature/client-does-not-hang
marcorossi5 Jul 11, 2024
409b236
client does not hang by default
marcorossi5 Jul 11, 2024
83fe8f7
refactor qibo client to look like IBM Qiskit interface
marcorossi5 Jul 12, 2024
242d9fc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 12, 2024
41498d7
test utils module
marcorossi5 Jul 13, 2024
a523ae9
Merge remote-tracking branch 'origin/feature/client-does-not-hang' in…
marcorossi5 Jul 13, 2024
307b46f
fix exception message
marcorossi5 Jul 13, 2024
d96cd3d
small changes
marcorossi5 Jul 13, 2024
c6752df
add qibo_job module tests
marcorossi5 Jul 13, 2024
cad264a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2024
8c5965f
add trailing slashes to url paths
marcorossi5 Jul 14, 2024
8e7aea5
cover qibo client tests
marcorossi5 Jul 14, 2024
2498ed0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2024
7c4813c
add verbose logs
marcorossi5 Jul 14, 2024
6a39a83
Merge remote-tracking branch 'origin/feature/client-does-not-hang' in…
marcorossi5 Jul 14, 2024
79e78be
remove | syntax for linting
marcorossi5 Jul 14, 2024
f362135
fix test
marcorossi5 Jul 14, 2024
6c780a2
add responses to test dependencies
marcorossi5 Jul 14, 2024
f572162
read minimum qibo version allowed from server
marcorossi5 Jul 14, 2024
11130a4
remove deprecated endpoint
marcorossi5 Jul 18, 2024
b780fc8
use pathlib instead of open
marcorossi5 Jul 25, 2024
5fc6ec1
conform examples
marcorossi5 Jul 25, 2024
6a04a05
update readme to use new interface
marcorossi5 Jul 25, 2024
9c85b3f
requests made through utility function
marcorossi5 Jul 25, 2024
f9f82a2
complete coverage
marcorossi5 Jul 26, 2024
080a97c
fix tests
marcorossi5 Aug 1, 2024
2f5d563
fix tests
marcorossi5 Aug 1, 2024
55fd2cd
remove qijobresult class
marcorossi5 Aug 1, 2024
cfbdb01
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 1, 2024
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ token = "your-token"
client = qibo_client.Client(token)

# run the circuit
result = client.run_circuit(circuit, nshots=1000, device="sim")
job = client.run_circuit(circuit, nshots=1000, device="sim")
result = job.result()
print(result)
```
12 changes: 6 additions & 6 deletions examples/run_error_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
from qibo_client import Client

# create the circuit you want to run
circuit = qibo.models.QFT(11)
circuit = qibo.models.QFT(26)

# read the token from file
token_path = Path(__file__).parent / "token.txt"
with open(token_path) as f:
token = f.read()
token = token_path.read_text()

# authenticate to server through the client instance
client = Client(token)

# run the circuit
print(f"{'*'*20}\nPost first circuit")
result = client.run_circuit(circuit, nshots=100, device="sim")

print(result)
start = time.time()
job = client.run_circuit(circuit, nshots=100, device="sim")
print(job.result())
print(f"Program done in {time.time() - start:.4f}s")
3 changes: 1 addition & 2 deletions examples/run_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

# read the token from file
token_path = Path(__file__).parent / "token.txt"
with open(token_path) as f:
token = f.read()
token = token_path.read_text()

# authenticate to server through the client instance
start = time.time()
Expand Down
9 changes: 4 additions & 5 deletions examples/run_successful_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

# read the token from file
token_path = Path(__file__).parent / "token.txt"
with open(token_path) as f:
token = f.read()
token = token_path.read_text()

# authenticate to server through the client instance
client = Client(token)

# run the circuit
print(f"{'*'*20}\nPost first circuit")
print(f"{'*'*20}\nPost circuit")
start = time.time()
result = client.run_circuit(circuit, nshots=100, device="sim")
print(result)
job = client.run_circuit(circuit, nshots=100, device="sim")
print(job.result())
print(f"Program done in {time.time() - start:.4f}s")
2 changes: 2 additions & 0 deletions jobs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
80 changes: 79 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pdbpp = "^0.10.3"
pytest = "^7.4.3"
pytest-cov = "^4.1.0"
pylint = "^3.0.3"
responses = "^0.25.3"

[tool.poetry.group.docs.dependencies]
sphinx = "^7.2.6"
Expand Down
1 change: 1 addition & 0 deletions src/qibo_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
__version__ = im.version(__package__)

from .qibo_client import Client
from .qibo_job import QiboJob, QiboJobResult, QiboJobStatus
3 changes: 1 addition & 2 deletions src/qibo_client/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
from pathlib import Path

MINIMUM_QIBO_VERSION_ALLOWED = "0.2.4"

RESULTS_BASE_FOLDER = Path(os.environ.get("RESULTS_BASE_FOLDER", "/tmp/qibo_client"))
SECONDS_BETWEEN_CHECKS = os.environ.get("SECONDS_BETWEEN_CHECKS", 2)

BASE_URL = "https://cloud.qibo.science"
TIMEOUT = 60
8 changes: 8 additions & 0 deletions src/qibo_client/config.py → src/qibo_client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ class JobPostServerError(Exception):
def __init__(self, message="Server failed to post job to queue"):
self.message = message
super().__init__(self.message)


class JobApiError(Exception):
def __init__(self, status_code: int, message: str):
self.status_code = status_code
self.message = message
self.displayed_message = f"[{self.status_code} Error] {self.message}"
super().__init__(self.displayed_message)
Loading