Skip to content

Commit

Permalink
fix arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
korgan00 committed Dec 11, 2024
1 parent f9994f9 commit 1760498
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
9 changes: 7 additions & 2 deletions client/qiskit_serverless/core/clients/local_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
20 changes: 9 additions & 11 deletions tests/docker/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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."""

Expand Down

0 comments on commit 1760498

Please sign in to comment.