Library to interact with qcentroid agent api
Project description
qcentroid-agent-cli
Client library to interact with qcentroid agent API.
Functions
Functions:
- obtain status, and context
- obtain input data
- send output data
- set status
- send execution logs
Install
pip install qcentroid-agent-cli
Use
As external agent:
from qcentroid_agent_cli import QCentroidSolverClient
base_url="https://api.qcentroid.xyz"
api_key="1234-4567-8910"
solver_id="123"
def main():
print("Hello QCentroid Agent!")
solver = QCentroidSolverClient(base_url, api_key, solver_id)
exit = False
while not exit: # put some escape function
try:
job = solver.obtainJob()
if job :
try:
job.start()
input_data = job.obtainInputData()
output_data = {}
#TODO: add your code here to generate output_data
job.sendOutputData(output_data)
#TODO: job.sendExecutionLog(logs)
job.end()
except Exception as e:
# job execution has failed, notify the platform about the error
job.error(e)
else:
# Wait for 1 minute before the next iteration
time.sleep(60)
except requests.RequestException as e:
# parameters are incorrect, url, api-key or solver_id, or infrastructure
print(f"Request failed: {e}")
exit=True
if __name__ == "__main__":
main()
As agent:
from qcentroid_agent_cli import QCentroidAgentClient
base_url = "https://api.qcentroid.xyz"
# job-id from EXECUTION_ID env var
# token from QCENTROID_TOKEN env var
job = QCentroidAgentClient(base_url)
data = None
try:
job.start()
data = job.obtainData()
#TODO job with data
job.sendData(data)
job.end()
except BaseException as be:
job.error(be)
#end
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
Close
Hashes for qcentroid_agent_cli-0.3.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b302ce2d6807b49c9010bf522f87566bb44f50f14fe422b95fe783b5200f88fc |
|
MD5 | bbd48d6ea46acff03388bc5653a80392 |
|
BLAKE2b-256 | b237acb7e9fd82e11934ee0154826ba514c860b55691d7972483e98af03fecff |
Close
Hashes for qcentroid_agent_cli-0.3.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01b123df120bd536d98934b5f9ba2528d862ee246fe0fda3eeb65f3587702115 |
|
MD5 | bb304ea6f298ddda2f968206e1b97339 |
|
BLAKE2b-256 | e2794764956b1938ca2cf1bb9e8b4a9179cca5bb86de73e39792e132f8ddd198 |