Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mila automation alliancecan #117

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sarc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def ssh(self):
fconfig = FabricConfig()
else:
fconfig = FabricConfig(ssh_config=SSHConfig.from_path(self.sshconfig))
fconfig["run"]["pty"] = True
fconfig["run"]["pty"] = False
fconfig["run"]["in_stream"] = False
return Connection(self.host, config=fconfig)

Expand Down
2 changes: 1 addition & 1 deletion sarc/jobs/sacct.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def fetch_raw(self) -> dict:
end = self.end.strftime(fmt)
accounts = self.cluster.accounts and ",".join(self.cluster.accounts)
accounts_option = f"-A {accounts}" if accounts else ""
cmd = f"{self.cluster.sacct_bin} {accounts_option} -X -S '{start}' -E '{end}' --allusers --json"
cmd = f"{self.cluster.sacct_bin} {accounts_option} -X -S {start} -E {end} --allusers --json"
logger.info(f"{self.cluster.name} $ {cmd}")
if self.cluster.host == "localhost":
results = subprocess.run(
Expand Down
30 changes: 15 additions & 15 deletions tests/functional/jobs/test_func_sacct.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test_scraper_with_malformed_cache(test_config, remote, scraper, caplog):

channel = remote.expect(
host="patate",
cmd="/opt/slurm/bin/sacct -X -S '2023-02-14T00:00' -E '2023-02-15T00:00' --allusers --json",
cmd="/opt/slurm/bin/sacct -X -S 2023-02-14T00:00 -E 2023-02-15T00:00 --allusers --json",
out=b"{}",
)

Expand All @@ -271,7 +271,7 @@ def test_sacct_bin_and_accounts(test_config, remote):
)
channel = remote.expect(
host="patate",
cmd="/opt/software/slurm/bin/sacct -A rrg-bonhomme-ad_gpu,rrg-bonhomme-ad_cpu,def-bonhomme_gpu,def-bonhomme_cpu -X -S '2023-02-14T00:00' -E '2023-02-15T00:00' --allusers --json",
cmd="/opt/software/slurm/bin/sacct -A rrg-bonhomme-ad_gpu,rrg-bonhomme-ad_cpu,def-bonhomme_gpu,def-bonhomme_cpu -X -S 2023-02-14T00:00 -E 2023-02-15T00:00 --allusers --json",
out=b'{"jobs": []}',
)

Expand Down Expand Up @@ -309,7 +309,7 @@ def test_stdout_message_before_json(
):
channel = remote.expect(
host="raisin",
cmd="/opt/slurm/bin/sacct -X -S '2023-02-15T00:00' -E '2023-02-16T00:00' --allusers --json",
cmd="/opt/slurm/bin/sacct -X -S 2023-02-15T00:00 -E 2023-02-16T00:00 --allusers --json",
out=f"Welcome on raisin,\nThe sweetest supercomputer in the world!\n{sacct_json}".encode(
"utf-8"
),
Expand Down Expand Up @@ -350,7 +350,7 @@ def test_get_gpu_type_from_prometheus(
):
channel = remote.expect(
host="raisin",
cmd="/opt/slurm/bin/sacct -X -S '2023-02-15T00:00' -E '2023-02-16T00:00' --allusers --json",
cmd="/opt/slurm/bin/sacct -X -S 2023-02-15T00:00 -E 2023-02-16T00:00 --allusers --json",
out=f"Welcome on raisin,\nThe sweetest supercomputer in the world!\n{sacct_json}".encode(
"utf-8"
),
Expand Down Expand Up @@ -416,7 +416,7 @@ def test_get_gpu_type_without_prometheus(
):
channel = remote.expect(
host="raisin_no_prometheus",
cmd="/opt/slurm/bin/sacct -X -S '2023-02-15T00:00' -E '2023-02-16T00:00' --allusers --json",
cmd="/opt/slurm/bin/sacct -X -S 2023-02-15T00:00 -E 2023-02-16T00:00 --allusers --json",
out=f"Welcome on raisin_no_prometheus,\nThe sweetest supercomputer in the world!\n{sacct_json}".encode(
"utf-8"
),
Expand Down Expand Up @@ -463,7 +463,7 @@ def test_save_job(
):
channel = remote.expect(
host="raisin",
cmd="/opt/slurm/bin/sacct -X -S '2023-02-15T00:00' -E '2023-02-16T00:00' --allusers --json",
cmd="/opt/slurm/bin/sacct -X -S 2023-02-15T00:00 -E 2023-02-16T00:00 --allusers --json",
out=sacct_json.encode("utf-8"),
)

Expand Down Expand Up @@ -504,7 +504,7 @@ def test_update_job(
host="raisin",
commands=[
Command(
cmd="/opt/slurm/bin/sacct -X -S '2023-02-15T00:00' -E '2023-02-16T00:00' --allusers --json",
cmd="/opt/slurm/bin/sacct -X -S 2023-02-15T00:00 -E 2023-02-16T00:00 --allusers --json",
out=sacct_json.encode("utf-8"),
)
for _ in range(2)
Expand Down Expand Up @@ -579,7 +579,7 @@ def test_save_preempted_job(
test_config, sacct_json, remote, file_regression, cli_main, prom_custom_query_mock
):
channel = remote.expect(
cmd="/opt/slurm/bin/sacct -X -S '2023-02-15T00:00' -E '2023-02-16T00:00' --allusers --json",
cmd="/opt/slurm/bin/sacct -X -S 2023-02-15T00:00 -E 2023-02-16T00:00 --allusers --json",
host="raisin",
out=sacct_json.encode("utf-8"),
)
Expand Down Expand Up @@ -625,8 +625,8 @@ def test_multiple_dates(
Command(
cmd=(
"/opt/slurm/bin/sacct -X "
f"-S '{job_submit_datetime.strftime('%Y-%m-%dT%H:%M')}' "
f"-E '{(job_submit_datetime + timedelta(days=1)).strftime('%Y-%m-%dT%H:%M')}' "
f"-S {job_submit_datetime.strftime('%Y-%m-%dT%H:%M')} "
f"-E {(job_submit_datetime + timedelta(days=1)).strftime('%Y-%m-%dT%H:%M')} "
"--allusers --json"
),
out=create_sacct_json(
Expand Down Expand Up @@ -714,15 +714,15 @@ def _create_session(cluster_name, cmd_template, datetimes):
channel = remote.expect_sessions(
_create_session(
"raisin",
"/opt/slurm/bin/sacct -X -S '{start}' -E '{end}' --allusers --json",
"/opt/slurm/bin/sacct -X -S {start} -E {end} --allusers --json",
datetimes=datetimes,
),
_create_session(
"patate",
(
"/opt/software/slurm/bin/sacct "
"-A rrg-bonhomme-ad_gpu,rrg-bonhomme-ad_cpu,def-bonhomme_gpu,def-bonhomme_cpu "
"-X -S '{start}' -E '{end}' --allusers --json"
"-X -S {start} -E {end} --allusers --json"
),
datetimes=datetimes,
),
Expand Down Expand Up @@ -825,15 +825,15 @@ def _create_session(cluster_name, cmd_template, datetimes):
channel = remote.expect_sessions(
_create_session(
"raisin",
"/opt/slurm/bin/sacct -X -S '{start}' -E '{end}' --allusers --json",
"/opt/slurm/bin/sacct -X -S {start} -E {end} --allusers --json",
datetimes=datetimes,
),
_create_session(
"patate",
(
"/opt/software/slurm/bin/sacct "
"-A rrg-bonhomme-ad_gpu,rrg-bonhomme-ad_cpu,def-bonhomme_gpu,def-bonhomme_cpu "
"-X -S '{start}' -E '{end}' --allusers --json"
"-X -S {start} -E {end} --allusers --json"
),
datetimes=datetimes,
),
Expand Down Expand Up @@ -943,7 +943,7 @@ def _create_session(cluster_name, cmd_template, datetimes):
def test_job_tz(test_config, sacct_json, remote, cli_main, prom_custom_query_mock):
channel = remote.expect(
host="patate",
cmd="/opt/software/slurm/bin/sacct -A rrg-bonhomme-ad_gpu,rrg-bonhomme-ad_cpu,def-bonhomme_gpu,def-bonhomme_cpu -X -S '2023-02-15T00:00' -E '2023-02-16T00:00' --allusers --json",
cmd="/opt/software/slurm/bin/sacct -A rrg-bonhomme-ad_gpu,rrg-bonhomme-ad_cpu,def-bonhomme_gpu,def-bonhomme_cpu -X -S 2023-02-15T00:00 -E 2023-02-16T00:00 --allusers --json",
out=sacct_json.encode("utf-8"),
)

Expand Down
10 changes: 5 additions & 5 deletions tests/unittests/jobs/test_sacct.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_SAcctScraper_fetch_raw(test_config, remote):
)
channel = remote.expect(
host="patate",
cmd="sacct -X -S '2023-02-28T00:00' -E '2023-03-01T00:00' --allusers --json",
cmd="sacct -X -S 2023-02-28T00:00 -E 2023-03-01T00:00 --allusers --json",
out=b"{}",
)
assert scraper.fetch_raw() == {}
Expand All @@ -33,11 +33,11 @@ def test_SAcctScraper_fetch_raw2(test_config, remote):
channel = remote.expect(
commands=[
Command(
"sacct -X -S '2023-02-28T00:00' -E '2023-03-01T00:00' --allusers --json",
"sacct -X -S 2023-02-28T00:00 -E 2023-03-01T00:00 --allusers --json",
out=b"{}",
),
Command(
"sacct -X -S '2023-02-28T00:00' -E '2023-03-01T00:00' --allusers --json",
"sacct -X -S 2023-02-28T00:00 -E 2023-03-01T00:00 --allusers --json",
out=b'{ "value": 2 }',
),
]
Expand Down Expand Up @@ -69,11 +69,11 @@ def test_SAcctScraper_get_cache(test_config, remote):
channel = remote.expect(
commands=[
Command(
f"sacct -X -S '{yesterday.strftime(fmt)}' -E '{today.strftime(fmt)}' --allusers --json",
f"sacct -X -S {yesterday.strftime(fmt)} -E {today.strftime(fmt)} --allusers --json",
out=b'{"value": 2}',
),
Command(
f"sacct -X -S '{today.strftime(fmt)}' -E '{tomorrow.strftime(fmt)}' --allusers --json",
f"sacct -X -S {today.strftime(fmt)} -E {tomorrow.strftime(fmt)} --allusers --json",
out=b'{"value": 2}',
),
]
Expand Down
Loading