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

[Bug] Gres written incorrectly when using Node model and slurmconfig editor #38

Closed
dsloanm opened this issue Dec 16, 2024 · 2 comments
Closed
Labels
Status: Triage Analysis of issue needs to completed before work can be undertaken. Type: Bug Issue reports a bug, or pull request fixes a bug.

Comments

@dsloanm
Copy link

dsloanm commented Dec 16, 2024

Bug Description

When using the slurmconfig editor with the Node model, Gres values are written out with commas separating each character of the string.

To Reproduce

Running:

from slurmutils.editors import slurmconfig
from slurmutils.models import Node

with slurmconfig.edit("slurm.conf") as config:
    node = Node(
        NodeName="ip-172-31-38-11",
        Gres="gpu:tesla_t4:1",
    )
    config.nodes.update(node.dict())

produces slurm.conf:

NodeName=ip-172-31-38-11 Gres=g,p,u,:,t,e,s,l,a,_,t,4,:,1

rather than expected:

NodeName=ip-172-31-38-11 Gres=gpu:tesla_t4:1

Environment

Running locally with the latest main commit: 60bc8e6.

Relevant log output

N/A

Additional context

No response

@dsloanm dsloanm added Status: Triage Analysis of issue needs to completed before work can be undertaken. Type: Bug Issue reports a bug, or pull request fixes a bug. labels Dec 16, 2024
@dsloanm dsloanm changed the title Gres written incorrectly when using Node model and slurmconfig editor [Bug] Gres written incorrectly when using Node model and slurmconfig editor Dec 16, 2024
@NucciTheBoss
Copy link
Member

Taking a quick peak at this issue, it's a symptom of #34 where we don't have good type checking enabled. Gres can be a comma-delimited list, which means that it's a list[str] type rather than just str. Since there's no real type checking, slurmutils will happily try to marshal a value using the assigned callback even if the value is the incorrect type.

The Gres configuration option is assigned the CommaSeparatorCallback so the value for Gres must be passed as a list:

Gres: Callback = CommaSeparatorCallback

The way to solve your issue here would be to pass the value of Gres as a list[str] rather than just a str:

from slurmutils.editors import slurmconfig
from slurmutils.models import Node

with slurmconfig.edit("slurm.conf") as config:
    node = Node(
        NodeName="ip-172-31-38-11",
        Gres=["gpu:tesla_t4:1"],
    )
    config.nodes.update(node.dict())

@dsloanm
Copy link
Author

dsloanm commented Dec 17, 2024

Can confirm using a list solves this.

@dsloanm dsloanm closed this as completed Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Analysis of issue needs to completed before work can be undertaken. Type: Bug Issue reports a bug, or pull request fixes a bug.
Projects
None yet
Development

No branches or pull requests

2 participants