QAnglesKit 0.0.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qangleskit-0.0.4.3/PKG-INFO +19 -0
- qangleskit-0.0.4.3/QAnglesKit/__init__.py +0 -0
- qangleskit-0.0.4.3/QAnglesKit/client.py +125 -0
- qangleskit-0.0.4.3/QAnglesKit.egg-info/PKG-INFO +19 -0
- qangleskit-0.0.4.3/QAnglesKit.egg-info/SOURCES.txt +9 -0
- qangleskit-0.0.4.3/QAnglesKit.egg-info/dependency_links.txt +1 -0
- qangleskit-0.0.4.3/QAnglesKit.egg-info/entry_points.txt +2 -0
- qangleskit-0.0.4.3/QAnglesKit.egg-info/requires.txt +3 -0
- qangleskit-0.0.4.3/QAnglesKit.egg-info/top_level.txt +1 -0
- qangleskit-0.0.4.3/setup.cfg +4 -0
- qangleskit-0.0.4.3/setup.py +28 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: QAnglesKit
|
|
3
|
+
Version: 0.0.4.3
|
|
4
|
+
Summary: A Python client library for interacting with quantum job details
|
|
5
|
+
Author: saipranay
|
|
6
|
+
Author-email: saipranay57@gmail.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Requires-Dist: pymongo
|
|
12
|
+
Requires-Dist: python-dotenv
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: author-email
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: requires-dist
|
|
18
|
+
Dynamic: requires-python
|
|
19
|
+
Dynamic: summary
|
|
File without changes
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import getpass
|
|
3
|
+
|
|
4
|
+
class QuantumJobDetails:
|
|
5
|
+
def __init__(self):
|
|
6
|
+
"""
|
|
7
|
+
Initialize the client with URLs for login, fetching, and storing job details.
|
|
8
|
+
"""
|
|
9
|
+
self.login_url = "http://54.211.133.186:5001/qangles_spcnj29p48fhnwe94ufifeliuh"
|
|
10
|
+
self.fetch_url = "http://54.211.133.186:5001/qangles_22wcjnr93iogfj4i9jornps"
|
|
11
|
+
self.store_url = "http://54.211.133.186:5001/qangles_24h4o8rusiurigvkjnrs5ps"
|
|
12
|
+
self.get_all_url = "http://54.211.133.186:5001/qangles_23li824ijrleijrnvi8hwps" # New URL for getting all jobs
|
|
13
|
+
self.session = requests.Session()
|
|
14
|
+
self.authenticated = False
|
|
15
|
+
|
|
16
|
+
def login(self):
|
|
17
|
+
"""
|
|
18
|
+
Authenticate the user interactively via the console.
|
|
19
|
+
:return: True if login is successful, False otherwise.
|
|
20
|
+
"""
|
|
21
|
+
username = input("Enter your email: ")
|
|
22
|
+
password = getpass.getpass("Enter your password: ")
|
|
23
|
+
|
|
24
|
+
# Extract customerID from email (part before @)
|
|
25
|
+
customer_id = username.split('@')[1].split('.')[0] if '@' in username else ""
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
response = self.session.post(self.login_url, json={
|
|
29
|
+
"Email": username,
|
|
30
|
+
"password": password,
|
|
31
|
+
"customerID": customer_id
|
|
32
|
+
})
|
|
33
|
+
if response.status_code == 200 and response.json().get("Status") == "Success":
|
|
34
|
+
print("Login successful.")
|
|
35
|
+
self.authenticated = True
|
|
36
|
+
return True
|
|
37
|
+
else:
|
|
38
|
+
print(f"Login failed: {response.status_code} - {response.text}")
|
|
39
|
+
self.authenticated = False
|
|
40
|
+
return False
|
|
41
|
+
except requests.RequestException as e:
|
|
42
|
+
print(f"Error during login: {e}")
|
|
43
|
+
self.authenticated = False
|
|
44
|
+
return False
|
|
45
|
+
|
|
46
|
+
def check_authentication(self):
|
|
47
|
+
"""
|
|
48
|
+
Check if the user is authenticated.
|
|
49
|
+
:return: None. Raises an exception if not authenticated.
|
|
50
|
+
"""
|
|
51
|
+
if not self.authenticated:
|
|
52
|
+
raise Exception("Not authenticated. Please login first.")
|
|
53
|
+
|
|
54
|
+
def fetch_job_details(self, job_id):
|
|
55
|
+
"""
|
|
56
|
+
Fetch details of a quantum job by its ID.
|
|
57
|
+
:param job_id: ID of the quantum job to retrieve.
|
|
58
|
+
:return: JSON response with job details.
|
|
59
|
+
"""
|
|
60
|
+
self.check_authentication()
|
|
61
|
+
try:
|
|
62
|
+
response = self.session.post(self.fetch_url, json={"job_id": job_id})
|
|
63
|
+
if response.status_code == 200:
|
|
64
|
+
response_data = response.json()
|
|
65
|
+
# Extract and return only the 'Details' part of the response
|
|
66
|
+
return response_data.get("Details")
|
|
67
|
+
else:
|
|
68
|
+
print(f"Failed to fetch job details: {response.status_code}")
|
|
69
|
+
return None
|
|
70
|
+
except requests.RequestException as e:
|
|
71
|
+
print(f"Error while fetching job details: {e}")
|
|
72
|
+
return None
|
|
73
|
+
|
|
74
|
+
def store_job_details(self, job_data):
|
|
75
|
+
"""
|
|
76
|
+
Store new quantum job details in the database.
|
|
77
|
+
:param job_data: Dictionary containing job details.
|
|
78
|
+
:return: JSON response with the status of the operation.
|
|
79
|
+
"""
|
|
80
|
+
self.check_authentication()
|
|
81
|
+
try:
|
|
82
|
+
response = self.session.post(self.store_url, json=job_data)
|
|
83
|
+
if response.status_code in [200, 201]:
|
|
84
|
+
print("Job saved successfully.")
|
|
85
|
+
return response.json().get("Details")
|
|
86
|
+
else:
|
|
87
|
+
print(f"Failed to save job: {response.status_code}")
|
|
88
|
+
return None
|
|
89
|
+
except requests.RequestException as e:
|
|
90
|
+
print(f"Error while saving job: {e}")
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
def get_all_jobs(self):
|
|
94
|
+
"""
|
|
95
|
+
Get all job IDs and titles.
|
|
96
|
+
:return: JSON response with job IDs and titles.
|
|
97
|
+
"""
|
|
98
|
+
self.check_authentication()
|
|
99
|
+
try:
|
|
100
|
+
response = self.session.get(self.get_all_url)
|
|
101
|
+
if response.status_code == 200:
|
|
102
|
+
return response.json().get("Details")
|
|
103
|
+
else:
|
|
104
|
+
print(f"Failed to fetch all jobs: {response.status_code}")
|
|
105
|
+
return None
|
|
106
|
+
except requests.RequestException as e:
|
|
107
|
+
print(f"Error while fetching all jobs: {e}")
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
# Example usage:
|
|
111
|
+
# client = QuantumJobDetails()
|
|
112
|
+
|
|
113
|
+
# if client.login():
|
|
114
|
+
# job_details = client.fetch_job_details(job_id=123)
|
|
115
|
+
# print(job_details)
|
|
116
|
+
|
|
117
|
+
# job_data = {
|
|
118
|
+
# "title": "Quantum Simulation",
|
|
119
|
+
# "description": "A job to simulate a quantum circuit.",
|
|
120
|
+
# "status": "pending"
|
|
121
|
+
# }
|
|
122
|
+
# client.store_job_details(job_data)
|
|
123
|
+
|
|
124
|
+
# all_jobs = client.get_all_jobs()
|
|
125
|
+
# print(all_jobs)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: QAnglesKit
|
|
3
|
+
Version: 0.0.4.3
|
|
4
|
+
Summary: A Python client library for interacting with quantum job details
|
|
5
|
+
Author: saipranay
|
|
6
|
+
Author-email: saipranay57@gmail.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Requires-Dist: pymongo
|
|
12
|
+
Requires-Dist: python-dotenv
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: author-email
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: requires-dist
|
|
18
|
+
Dynamic: requires-python
|
|
19
|
+
Dynamic: summary
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
setup.py
|
|
2
|
+
QAnglesKit/__init__.py
|
|
3
|
+
QAnglesKit/client.py
|
|
4
|
+
QAnglesKit.egg-info/PKG-INFO
|
|
5
|
+
QAnglesKit.egg-info/SOURCES.txt
|
|
6
|
+
QAnglesKit.egg-info/dependency_links.txt
|
|
7
|
+
QAnglesKit.egg-info/entry_points.txt
|
|
8
|
+
QAnglesKit.egg-info/requires.txt
|
|
9
|
+
QAnglesKit.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
QAnglesKit
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import setuptools
|
|
2
|
+
|
|
3
|
+
setuptools.setup(
|
|
4
|
+
name="QAnglesKit",
|
|
5
|
+
version="0.0.4.3",
|
|
6
|
+
author="saipranay",
|
|
7
|
+
author_email="saipranay57@gmail.com",
|
|
8
|
+
description="A Python client library for interacting with quantum job details",
|
|
9
|
+
packages=setuptools.find_packages(),
|
|
10
|
+
classifiers=[
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Operating System :: OS Independent",
|
|
14
|
+
],
|
|
15
|
+
python_requires='>=3.7', # Correct Python version specifier
|
|
16
|
+
install_requires=[
|
|
17
|
+
"pymongo",
|
|
18
|
+
"python-dotenv",
|
|
19
|
+
"requests"
|
|
20
|
+
],
|
|
21
|
+
entry_points={
|
|
22
|
+
"console_scripts": [
|
|
23
|
+
"mypackage-cli=mypackage.db_handler:main", # Optional CLI command
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|