Skip to content

Commit

Permalink
pass arguments by file instead of by envvar
Browse files Browse the repository at this point in the history
Signed-off-by: Paul S. Schweigert <[email protected]>
  • Loading branch information
psschwei committed Sep 24, 2024
1 parent fd873f7 commit 6cf6f11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion client/qiskit_serverless/serializers/program_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,8 @@ def get_arguments() -> Dict[str, Any]:
Returns:
Dictionary of arguments.
"""
return json.loads(os.environ.get(ENV_JOB_ARGUMENTS, "{}"), cls=QiskitObjectsDecoder)
arguments = "{}"
if os.path.isfile("arguments.serverless"):
with open("arguments.serverless", "r") as f:
arguments = f.read()
return json.loads(arguments, cls=QiskitObjectsDecoder)
6 changes: 6 additions & 0 deletions gateway/api/ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def submit(self, job: Job) -> Optional[str]:
# get entrypoint
entrypoint = f"python {program.entrypoint}"

# upload arguments to working directory
if job.arguments:
logger.debug("uploading arguments for job %s", job.id)
with open(working_directory_for_upload + "/arguments.serverless", "w") as f:
f.write(job.arguments)

# set tracing
carrier = {}
TraceContextTextMapPropagator().inject(carrier)
Expand Down
1 change: 0 additions & 1 deletion gateway/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def build_env_variables(token, job: Job, arguments: str) -> Dict[str, str]:
"ENV_JOB_GATEWAY_TOKEN": str(token),
"ENV_JOB_GATEWAY_HOST": str(settings.SITE_HOST),
"ENV_JOB_ID_GATEWAY": str(job.id),
"ENV_JOB_ARGUMENTS": arguments,
},
**extra,
}
Expand Down

0 comments on commit 6cf6f11

Please sign in to comment.