Package: qcentroid-agent-cli
qcentroid-agent-cliClient library to interact with QCentroid Agent API.FunctionsFunctions:obtain status, and contextobtain input datasend output dataset statussend execution logsInstallpipinstallqcentroid-agent-cliUseSimple exampleAs easy as this:fromqcentroid_agent_cliimportQCentroidSolverClientimportlogginglogging.basicConfig(level=logging.DEBUG)API_BASE_URL="https://api.qcentroid.xyz"SOLVER_API_KEY="1234-4567-8910"# Get your solver API_KEY in the platform dashboardSOLVER_ID="123"defmain():# Get the solver detailssolver=QCentroidSolverClient(API_BASE_URL,SOLVER_API_KEY,SOLVER_ID)# Request a queued jobjob=solver.obtainJob()# Notify start of job executionjob.start()# Retrieve the job input datainput_data=job.obtainInputData()output_data={}## TODO: Add your solver code here and generate output_data## Send the solver output data and execution logs to the platformjob.sendOutputData(output_data)job.sendExecutionLog(logs)# End of job executionif__name__=="__main__":main()Example for external agents:importrequestsfromqcentroid_agent_cliimportQCentroidSolverClientimportlogginglogging.basicConfig(level=logging.DEBUG)logger=logging.getLogger(__name__)API_BASE_URL="https://api.qcentroid.xyz"SOLVER_API_KEY="1234-4567-8910"# Get your solver API_KEY in the platform dashboardSOLVER_ID="123"defmain():exit=Falseprint("QCentroid Agent usage example")print("Starting...")# Initialize the agent and get the solver details and a valid access tokensolver=QCentroidSolverClient(API_BASE_URL,SOLVER_API_KEY,SOLVER_ID)print("Solver initialization successful.")# Loop to request queued jobs until any exit condition you want to setwhilenotexit:try:print("Checking for pending jobs...")# Request a queued job (the oldest one will be returned)job=solver.obtainJob()ifjob:print("New job received.")# There is a job to be processed!try:print("Processing job...")# Notify the platform we're starting to process this jobjob.start()# Retrieve the input datainput_data=job.obtainInputData()output_data={}## TODO: add your solver code here and generate output_data#print("Job processed successfully.")# Send the solver output data to the platformjob.sendOutputData(output_data)# Send the solver execution logs to check them thorugh the platform dashboard# TODO: job.sendExecutionLog(logs)job.end()exceptExceptionase:# Job execution has failed, notify the platform about the errorprint("Error during job execution.")job.error(e)else:# No queued jobs. Wait for 1 minute and check againprint("No pending jobs. Waiting for 1 minute...")time.sleep(60)exceptrequests.RequestExceptionase:# Error in an API request# Whether parameters are incorrect (URL, api-key or solver_id), or there are connectivity issuesprint(f"QCentroid Agent: API request failed:{e}")exit=TrueexceptExceptionase:# Any other errorsprint(f"QCentroid Agent error:{e}")exit=Trueprint("End.")if__name__=="__main__":main()VersioningUpdate manually on main thepyproject.tomltheversionfield to match the next release tag. Launch anew version on Releasessection selecting a new tag matching the version. Create the release. The release will be published on pypi.orgDebuging locallypipinstall.#install the current version of the componentpythonmain.py#run the client version that uses the package