Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Most of Sourcery-ai suggested changes accepted.

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
awicenec and sourcery-ai[bot] committed Jul 2, 2024
1 parent 1abd427 commit 1bd7ad3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 5 additions & 1 deletion daliuge-engine/dlg/deploy/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@


class DefaultConfig(object):
ACCOUNT = ""
class DefaultConfig(object):
def __init__(self, account):
self.ACCOUNT = account
HOME_DIR = os.environ["HOME"] if "HOME" in os.environ else ""
DLG_ROOT = f"{HOME_DIR}/dlg"
HOME_DIR = os.environ["HOME"] if "HOME" in os.environ else ""
DLG_ROOT = f"{HOME_DIR}/dlg"
LOG_DIR = f"{DLG_ROOT}/log"
Expand Down
11 changes: 8 additions & 3 deletions daliuge-engine/dlg/deploy/create_dlg_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def get_timestamp(line):
date_time = "{0}T{1}".format(split[0], split[1])
pattern = "%Y-%m-%dT%H:%M:%S,%f"
epoch = time.mktime(time.strptime(date_time, pattern))
return datetime.datetime.strptime(date_time, pattern).microsecond / 1e6 + epoch
parsed_date = datetime.datetime.strptime(date_time, pattern)
microseconds = parsed_date.microsecond / 1e6
return microseconds + epoch


class LogEntryPair:
Expand Down Expand Up @@ -610,7 +612,10 @@ def main():
)

(opts, _) = parser.parse_args(sys.argv)
if opts.configs:
(opts, _) = parser.parse_args(sys.argv)
if opts.configs:
print(f"Available facilities: {FACILITIES}")
sys.exit(1)
print(f"Available facilities: {FACILITIES}")
sys.exit(1)
if not (opts.action and opts.facility) and not opts.configs:
Expand Down Expand Up @@ -654,7 +659,7 @@ def main():
elif opts.physical_graph:
path_to_graph_file = opts.physical_graph
if path_to_graph_file and not os.path.exists(path_to_graph_file):
parser.error("Cannot locate graph file at '{0}'".format(path_to_graph_file))
parser.error(f"Cannot locate graph file at '{path_to_graph_file}'")
else:
graph_name = os.path.basename(path_to_graph_file)
with open(path_to_graph_file) as f:
Expand Down
2 changes: 1 addition & 1 deletion daliuge-engine/dlg/deploy/slurm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(
self._submit = submit
self._dtstr = datetime.datetime.now().strftime("%Y-%m-%dT%H-%M-%S") # .%f
ni, nn, self._pip_name = find_numislands(self._physical_graph_template_data)
if ni and ni >= self._num_islands:
if isinstance(ni, int) and ni >= self._num_islands:
self._num_islands = ni
if nn and nn >= self._num_nodes:
self._num_nodes = nn
Expand Down
5 changes: 4 additions & 1 deletion daliuge-engine/test/manager/test_dim.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ def setUp(self):
super(LocalDimStarter, self).setUp()
self.nm_info = self.start_nm_in_thread()
self.dm = self.nm_info.manager
self.dim = DataIslandManager([f"{nm_host}"])
def test_invalid_host_format(self):
invalid_host = "invalid_host_format"
with self.assertRaises(ValueError):
DataIslandManager([f"{invalid_host}"])

def tearDown(self):
self.nm_info.stop()
Expand Down

0 comments on commit 1bd7ad3

Please sign in to comment.