diff --git a/client/qiskit_serverless/core/clients/local_client.py b/client/qiskit_serverless/core/clients/local_client.py index 237808959..2afe026aa 100644 --- a/client/qiskit_serverless/core/clients/local_client.py +++ b/client/qiskit_serverless/core/clients/local_client.py @@ -112,11 +112,13 @@ def run( **(saved_program.env_vars or {}), **{OT_PROGRAM_NAME: saved_program.title}, **{"PATH": os.environ["PATH"]}, - **{ENV_JOB_ARGUMENTS: json.dumps(arguments, cls=QiskitObjectsEncoder)}, } + with open("arguments.serverless", "w", encoding="utf-8") as f: + json.dump(arguments, f, cls=QiskitObjectsEncoder) + with Popen( - ["python", saved_program.working_dir + saved_program.entrypoint], + ["python", os.path.join(saved_program.working_dir, saved_program.entrypoint)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, @@ -126,6 +128,9 @@ def run( if pipe.wait(): status = "FAILED" output, _ = pipe.communicate() + + os.remove("arguments.serverless") + results = re.search("\nSaved Result:(.+?):End Saved Result\n", output) result = "" if results: diff --git a/tests/docker/test_docker.py b/tests/docker/test_docker.py index 3fda19b8d..15ee9acca 100644 --- a/tests/docker/test_docker.py +++ b/tests/docker/test_docker.py @@ -2,7 +2,7 @@ """Tests jobs.""" import os -from pytest import fixture, raises, mark +from pytest import raises, mark from qiskit import QuantumCircuit from qiskit.circuit.random import random_circuit @@ -20,21 +20,15 @@ class TestFunctionsDocker: """Test class for integration testing with docker.""" - @fixture(scope="class") - def simple_function(self): - """Fixture of a simple function""" - return QiskitFunction( + @mark.order(1) + def test_simple_function(self, any_client: BaseClient): + """Integration test function uploading.""" + simple_function = QiskitFunction( title="my-first-pattern", entrypoint="pattern.py", working_dir=resources_path, ) - @mark.order(1) - def test_simple_function( - self, any_client: BaseClient, simple_function: QiskitFunction - ): - """Integration test function uploading.""" - runnable_function = any_client.upload(simple_function) assert runnable_function is not None @@ -143,6 +137,10 @@ def test_multiple_runs(self, any_client: BaseClient): assert isinstance(retrieved_job1.logs(), str) assert isinstance(retrieved_job2.logs(), str) + @mark.skip( + reason="Images are not working in tests jet and " + + "LocalClient does not manage image instead of working_dir+entrypoint" + ) def test_error(self, any_client: BaseClient): """Integration test to force an error."""