-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jizong
committed
Oct 31, 2019
1 parent
651f272
commit c1a1d2b
Showing
5 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
GPUQueue.egg-info/ | ||
build/ | ||
dist/ | ||
**/*.pyc | ||
**/*.pyc | ||
log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .main import JobSubmitter | ||
from .main import JobSubmitter | ||
from .stdout_writer import log_writer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from datetime import datetime | ||
from pathlib import Path | ||
import time | ||
|
||
class log_writer: | ||
def __init__(self, job_script: str, save_dir="log") -> None: | ||
super().__init__() | ||
self.job_script = job_script | ||
self.launch_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') | ||
self.save_dir = save_dir | ||
if self.save_dir: | ||
Path(save_dir).mkdir(exist_ok=True, parents=True) | ||
print(f"Job {self.job_script}->`job_{self.launch_time}.log`") | ||
time.sleep(1) | ||
|
||
def __enter__(self): | ||
if self.save_dir: | ||
self.f = open(f"{str(Path(self.save_dir) / ('job_' + self.launch_time + '.log'))}", "w") | ||
else: | ||
self.f = open(f"job_{self.launch_time}.log") | ||
self.f.writelines(self.job_script) | ||
self.f.writelines(f"\nlaunched at {self.launch_time}\n") | ||
self.f.writelines("output log:\n") | ||
return self.f | ||
|
||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
self.f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters