From 7402e53a770f6feb036a4aaf639b1a0fe77f58e2 Mon Sep 17 00:00:00 2001 From: Gregorio Iniesta Date: Thu, 17 Oct 2024 19:02:47 +0200 Subject: [PATCH] fix upload return on local client --- .../core/clients/local_client.py | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/client/qiskit_serverless/core/clients/local_client.py b/client/qiskit_serverless/core/clients/local_client.py index 5a8016861..0dd03faba 100644 --- a/client/qiskit_serverless/core/clients/local_client.py +++ b/client/qiskit_serverless/core/clients/local_client.py @@ -163,37 +163,30 @@ def filtered_logs(self, job_id: str, **kwargs): ####### Functions ####### ######################### - def upload(self, program: QiskitFunction): + def upload(self, program: QiskitFunction) -> Optional[QiskitFunction]: # check if entrypoint exists if not os.path.exists(os.path.join(program.working_dir, program.entrypoint)): raise QiskitServerlessException( f"Entrypoint file [{program.entrypoint}] does not exist " f"in [{program.working_dir}] working directory." ) - self._patterns.append( - { - "title": program.title, - "provider": program.provider, - "entrypoint": program.entrypoint, - "working_dir": program.working_dir, - "env_vars": program.env_vars, - "arguments": json.dumps({}), - "dependencies": json.dumps(program.dependencies or []), - } - ) - return program.title + + pattern = { + "title": program.title, + "provider": program.provider, + "entrypoint": program.entrypoint, + "working_dir": program.working_dir, + "env_vars": program.env_vars, + "arguments": json.dumps({}), + "dependencies": json.dumps(program.dependencies or []), + "client": self, + } + self._patterns.append(pattern) + return QiskitFunction.from_json(pattern) def functions(self, **kwargs) -> List[QiskitFunction]: """Returns list of programs.""" - return [ - QiskitFunction( - program.get("title"), - provider=program.get("provider", None), - raw_data=program, - client=self, - ) - for program in self._patterns - ] + return [QiskitFunction.from_json(program) for program in self._patterns] def function( self, title: str, provider: Optional[str] = None