Skip to content

Commit

Permalink
Merge pull request #204 from mila-iqia/postpone-jobs-age-check
Browse files Browse the repository at this point in the history
Postpone clusters status display feature
  • Loading branch information
soline-b authored Oct 8, 2024
2 parents 855666f + 0097598 commit fbfd46f
Show file tree
Hide file tree
Showing 28 changed files with 185 additions and 122 deletions.
1 change: 1 addition & 0 deletions clockwork_frontend_test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Import fixture fake data so that we can use it in tests from this module."""

from test_common.fake_data import fake_data
2 changes: 1 addition & 1 deletion clockwork_frontend_test/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
job["slurm"]["job_state"].lower(),
get_default_display_date(job["slurm"]["submit_time"]),
get_default_display_date(job["slurm"]["start_time"]),
get_default_display_date(job["slurm"]["end_time"])
get_default_display_date(job["slurm"]["end_time"]),
# Then, there is the "Links" column: we don't add content yet,
# but here is a placeholder for future testing
]
Expand Down
128 changes: 80 additions & 48 deletions clockwork_frontend_test/test_jobs_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@
JOBS_SEARCH_DEFAULT_TABLE.append(
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
)

ALL_JOBS = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -125,9 +129,11 @@ def test_filter_by_user_only_me(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -186,9 +192,11 @@ def test_filter_by_user_other_user(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -241,9 +249,11 @@ def test_filter_by_cluster_except_one(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -304,9 +314,11 @@ def test_filter_by_cluster_except_two(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -366,9 +378,11 @@ def test_filter_by_status_except_one(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -429,9 +443,11 @@ def test_filter_by_status_except_two(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -499,9 +515,11 @@ def test_multiple_filters(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -548,9 +566,11 @@ def test_filter_by_job_array(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -600,9 +620,11 @@ def test_filter_by_job_user_props(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -680,9 +702,11 @@ def test_special_user_props(page: Page, prop_name: str, title: str):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -732,9 +756,11 @@ def test_jobs_table_sorting_by_cluster(page: Page):
expected_content = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted(
Expand All @@ -749,9 +775,11 @@ def test_jobs_table_sorting_by_job_id(page: Page):
expected_content = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted(
Expand All @@ -769,9 +797,11 @@ def test_jobs_table_sorting_by_job_id_ascending(page: Page):
expected_content = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted(fake_data["jobs"], key=lambda j: j["slurm"]["job_id"])
Expand All @@ -786,9 +816,11 @@ def test_jobs_table_sorting_by_end_time(page: Page):
expected_content = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted(
Expand Down
40 changes: 25 additions & 15 deletions clockwork_frontend_test/test_jobs_search_for_student06.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
MILA_JOBS.append(
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
)
Expand Down Expand Up @@ -273,9 +275,11 @@ def test_filter_by_status_except_one(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_mila_jobs
Expand Down Expand Up @@ -335,9 +339,11 @@ def test_filter_by_status_except_two(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_mila_jobs
Expand Down Expand Up @@ -404,9 +410,11 @@ def test_multiple_filters(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted_jobs
Expand Down Expand Up @@ -478,9 +486,11 @@ def test_jobs_table_sorting_by_end_time(page: Page):
expected_results = [
[
job["slurm"]["cluster_name"],
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else "",
(
job["cw"]["mila_email_username"].replace("@", " @")
if job["cw"]["mila_email_username"] is not None
else ""
),
job["slurm"]["job_id"],
]
for job in sorted(
Expand Down
10 changes: 5 additions & 5 deletions clockwork_tools/clockwork_tools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def jobs_list(
"""
endpoint = "api/v1/clusters/jobs/list"
params = {}
for (k, a) in [
for k, a in [
("username", username),
("relative_time", relative_time),
("cluster_name", cluster_name),
Expand All @@ -154,7 +154,7 @@ def jobs_one(self, job_id: str = None, cluster_name: str = None) -> dict[str, an
"""
endpoint = "api/v1/clusters/jobs/one"
params = {}
for (k, a) in [
for k, a in [
("job_id", job_id),
("cluster_name", cluster_name),
]:
Expand Down Expand Up @@ -231,7 +231,7 @@ def nodes_list(self, cluster_name: str = None) -> list[dict[str, any]]:
"""
endpoint = "api/v1/clusters/nodes/list"
params = {}
for (k, a) in [
for k, a in [
("cluster_name", cluster_name),
]:
if a is not None:
Expand All @@ -258,7 +258,7 @@ def nodes_one(
"""
endpoint = "api/v1/clusters/nodes/one"
params = {}
for (k, a) in [
for k, a in [
("node_name", node_name),
("cluster_name", cluster_name),
]:
Expand Down Expand Up @@ -337,7 +337,7 @@ def _create_params_for_request(self, target_self: bool, **kwargs):
preparing arguments to pass to a request in the parent class.
"""
params = {}
for (k, a) in kwargs.items():
for k, a in kwargs.items():
if a is not None:
params[k] = a
elif target_self and k in self.this_specific_slurm_job_params:
Expand Down
2 changes: 1 addition & 1 deletion clockwork_tools_test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def config():
"email": os.environ["clockwork_tools_test_EMAIL"],
"clockwork_api_key": os.environ["clockwork_tools_test_CLOCKWORK_API_KEY"],
}
for (k, v) in config.items():
for k, v in config.items():
assert v, f"Missing value in environment for clockwork_tools configuration {k}."
return config

Expand Down
2 changes: 1 addition & 1 deletion clockwork_tools_test/test_mt_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_get_nodes_with_filter(mtclient, fake_data, cluster_name):
)

# compare all the dicts one by one
for (D_node, D_original_node) in zip(LD_nodes, LD_original_nodes):
for D_node, D_original_node in zip(LD_nodes, LD_original_nodes):
for k1 in D_original_node:
assert k1 in ["slurm", "cw"]
assert k1 in D_node, f"{D_node.keys()}"
Expand Down
1 change: 1 addition & 0 deletions clockwork_web/browser_routes/clusters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Browser routes dealing with the "cluster" entity
"""

import logging

from flask import Blueprint, request
Expand Down
Loading

0 comments on commit fbfd46f

Please sign in to comment.