diff --git a/src/braket/jobs/_entry_point_template.py b/src/braket/jobs/_entry_point_template.py index 3b8e8ccc4..285e4d85e 100644 --- a/src/braket/jobs/_entry_point_template.py +++ b/src/braket/jobs/_entry_point_template.py @@ -38,6 +38,7 @@ def make_link(input_link_path, input_data_path, links): def link_input(): links = {{}} + dirs = set() # map of data sources to lists of matched local files prefix_matches = {prefix_matches} @@ -67,4 +68,12 @@ def clean_links(links): for link, target in links.items(): if link.is_symlink and link.readlink() == target: link.unlink() + + if link.is_relative_to(Path()): + for dir in link.parents[:-1]: + try: + dir.rmdir() + except: + # directory not empty + pass ''' diff --git a/test/integ_tests/test_create_quantum_job.py b/test/integ_tests/test_create_quantum_job.py index 753b26fea..cf38560db 100644 --- a/test/integ_tests/test_create_quantum_job.py +++ b/test/integ_tests/test_create_quantum_job.py @@ -227,7 +227,7 @@ def decorator_job(a, b: int, c=0, d: float = 1.0, **extras): "extra_arg": "extra_value", } - with open("output_file.txt", "w") as f: + with open("test/output_file.txt", "w") as f: f.write("hello") job = decorator_job(MyClass(), 2, d=5, extra_arg="extra_value") @@ -237,12 +237,13 @@ def decorator_job(a, b: int, c=0, d: float = 1.0, **extras): with tempfile.TemporaryDirectory() as temp_dir: os.chdir(temp_dir) job.download_result() + with open(Path(job.name, "test", "output_file.txt"), "r") as f: + assert f.read() == "hello" assert ( Path(job.name, "results.json").exists() - and not Path(job.name, "test", "integ_tests", "requirements.txt").exists() + and Path(job.name, "test").exists() + and not Path(job.name, "test", "integ_tests").exists() ) - with open(Path(job.name, "output_file.txt"), "r") as f: - assert f.read() == "hello" os.chdir(current_dir)