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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

Supported by

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