Skip to content

Commit 37bd4c4

Browse files
szachovyCopilot
andcommitted
Clean up temporary .pyc files on remote nodes after execution
Remove the uploaded .pyc file after run_python_container_command() completes to prevent accumulation across multiple deployment runs. Closes #51 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0ab8ce7 commit 37bd4c4

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
* Completed [ARCHITECTURE.md](./docs/ARCHITECTURE.md) (#93)
2222
* Migrated CI from self-hosted to GitHub-hosted runners with Docker-in-Docker test infrastructure. (#94)
2323
* Test workflow always builds service images locally for reproducibility. (#97)
24+
* Clean up temporary `.pyc` files on remote nodes after execution. (#51)
2425

2526
### Fixed
2627

src/remote.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@ def run_python_container_command(self, command: str) -> dict:
130130
marshal.dump(code_object, pyc_file)
131131
self.upload_file(content=pyc_file.getvalue(), remote_file_path=f'/opt/{nonce}.pyc')
132132
_, stdout, stderr = self.ssh_client.exec_command(f"python3 /opt/{nonce}.pyc")
133-
return {
133+
result = {
134134
"output": stdout.read().decode(),
135135
"error": stderr.read().decode()
136136
}
137+
self.ssh_client.exec_command(f"rm -f /opt/{nonce}.pyc")
138+
return result
137139

138140
def upload_directory(self, local_directory_path: str, remote_directory_path: str) -> None:
139141
stack = [(local_directory_path, remote_directory_path)]

0 commit comments

Comments
 (0)