Skip to content

Commit

Permalink
fix: decorator job with no inner function (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
yitchen-tim authored Feb 10, 2025
1 parent b533b89 commit d3aa29b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/braket/jobs/hybrid_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,17 @@ def persist_inner_function_source(entry_point: callable) -> None:
"""
inner_source_mapping = _get_inner_function_source(entry_point.__code__)

with tempfile.TemporaryDirectory() as temp_dir:
copy_dir = f"{temp_dir}/{INNER_FUNCTION_SOURCE_INPUT_FOLDER}"
os.mkdir(copy_dir)
path_mapping = _save_inner_source_to_file(inner_source_mapping, copy_dir)
entry_point.__code__ = _replace_inner_function_source_path(
entry_point.__code__, path_mapping
)
yield {INNER_FUNCTION_SOURCE_INPUT_CHANNEL: copy_dir}
if len(inner_source_mapping) == 0:
yield {}
else:
with tempfile.TemporaryDirectory(dir="", prefix="decorator_job_inner_source_") as temp_dir:
copy_dir = f"{temp_dir}/{INNER_FUNCTION_SOURCE_INPUT_FOLDER}"
os.mkdir(copy_dir)
path_mapping = _save_inner_source_to_file(inner_source_mapping, copy_dir)
entry_point.__code__ = _replace_inner_function_source_path(
entry_point.__code__, path_mapping
)
yield {INNER_FUNCTION_SOURCE_INPUT_CHANNEL: copy_dir}


def _replace_inner_function_source_path(
Expand Down

0 comments on commit d3aa29b

Please sign in to comment.