Skip to main content

Library to interact with qcentroid agent api

Project description

qcentroid-agent-cli

deploy to pypi Python PyPI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qcentroid_agent_cli-0.3.10.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qcentroid_agent_cli-0.3.10-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file qcentroid_agent_cli-0.3.10.tar.gz.

File metadata

  • Download URL: qcentroid_agent_cli-0.3.10.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for qcentroid_agent_cli-0.3.10.tar.gz
Algorithm Hash digest
SHA256 b302ce2d6807b49c9010bf522f87566bb44f50f14fe422b95fe783b5200f88fc
MD5 bbd48d6ea46acff03388bc5653a80392
BLAKE2b-256 b237acb7e9fd82e11934ee0154826ba514c860b55691d7972483e98af03fecff

See more details on using hashes here.

File details

Details for the file qcentroid_agent_cli-0.3.10-py3-none-any.whl.

File metadata

File hashes

Hashes for qcentroid_agent_cli-0.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 01b123df120bd536d98934b5f9ba2528d862ee246fe0fda3eeb65f3587702115
MD5 bb304ea6f298ddda2f968206e1b97339
BLAKE2b-256 e2794764956b1938ca2cf1bb9e8b4a9179cca5bb86de73e39792e132f8ddd198

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page