# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
from dataclasses import dataclass

from gcm.monitoring.coerce import maybe_int
from gcm.schemas.dataclass import parsed_field
from gcm.schemas.slurm.derived_cluster import DerivedCluster


@dataclass(kw_only=True)
class ScontrolConfig(DerivedCluster):
    """Schema for scontrol show config output."""

    cluster: str
    # Common scontrol show config fields
    # Using str for string fields
    # Using maybe_int for integer fields to handle potential None values

    # Original fields
    ClusterName: str | None = parsed_field(parser=str)
    ControlMachine: str | None = parsed_field(parser=str)
    ControlAddr: str | None = parsed_field(parser=str)
    BackupController: str | None = parsed_field(parser=str)
    BackupAddr: str | None = parsed_field(parser=str)
    SlurmUser: str | None = parsed_field(parser=str)
    SlurmUID: int | None = parsed_field(parser=maybe_int)
    SlurmdUser: str | None = parsed_field(parser=str)
    SlurmdUID: int | None = parsed_field(parser=maybe_int)
    AuthType: str | None = parsed_field(parser=str)
    AuthInfo: str | None = parsed_field(parser=str)
    CryptoType: str | None = parsed_field(parser=str)
    JobCredentialPrivateKey: str | None = parsed_field(parser=str)
    JobCredentialPublicCertificate: str | None = parsed_field(parser=str)
    StateSaveLocation: str | None = parsed_field(parser=str)
    SlurmdSpoolDir: str | None = parsed_field(parser=str)
    SlurmctldLogFile: str | None = parsed_field(parser=str)
    SlurmdLogFile: str | None = parsed_field(parser=str)
    SlurmctldDebug: str | None = parsed_field(parser=str)
    SlurmdDebug: str | None = parsed_field(parser=str)
    SlurmctldPidFile: str | None = parsed_field(parser=str)
    SlurmdPidFile: str | None = parsed_field(parser=str)
    SlurmctldPort: str | None = parsed_field(parser=str)
    SlurmdPort: int | None = parsed_field(parser=maybe_int)
    SlurmctldTimeout: str | None = parsed_field(parser=str)
    SlurmdTimeout: str | None = parsed_field(parser=str)
    InactiveLimit: str | None = parsed_field(parser=str)
    MinJobAge: str | None = parsed_field(parser=str)
    KillWait: str | None = parsed_field(parser=str)
    Waittime: int | None = parsed_field(parser=maybe_int)
    SchedulerType: str | None = parsed_field(parser=str)
    SchedulerParameters: str | None = parsed_field(parser=str)
    SelectType: str | None = parsed_field(parser=str)
    SelectTypeParameters: str | None = parsed_field(parser=str)
    PriorityType: str | None = parsed_field(parser=str)
    PriorityDecayHalfLife: str | None = parsed_field(parser=str)
    PriorityCalcPeriod: str | None = parsed_field(parser=str)
    PriorityFavorSmall: str | None = parsed_field(parser=str)
    PriorityMaxAge: str | None = parsed_field(parser=str)
    PriorityUsageResetPeriod: str | None = parsed_field(parser=str)
    PriorityWeightAge: int | None = parsed_field(parser=maybe_int)
    PriorityWeightFairShare: int | None = parsed_field(parser=maybe_int)
    PriorityWeightJobSize: int | None = parsed_field(parser=maybe_int)
    PriorityWeightPartition: int | None = parsed_field(parser=maybe_int)
    PriorityWeightQOS: int | None = parsed_field(parser=maybe_int)
    AccountingStorageType: str | None = parsed_field(parser=str)
    AccountingStorageHost: str | None = parsed_field(parser=str)
    AccountingStoragePort: int | None = parsed_field(parser=maybe_int)
    AccountingStorageUser: str | None = parsed_field(parser=str)
    AccountingStorageLoc: str | None = parsed_field(parser=str)
    AccountingStorageEnforce: str | None = parsed_field(parser=str)
    JobAcctGatherType: str | None = parsed_field(parser=str)
    JobAcctGatherFrequency: str | None = parsed_field(parser=str)
    SlurmctldAddr: str | None = parsed_field(parser=str)
    FrontendName: str | None = parsed_field(parser=str)
    FrontendAddr: str | None = parsed_field(parser=str)
    NodeName: str | None = parsed_field(parser=str)
    NodeAddr: str | None = parsed_field(parser=str)
    PartitionName: str | None = parsed_field(parser=str)

    # Additional fields from sample-scontrol-show-config-output-h2.txt
    AccountingStorageBackupHost: str | None = parsed_field(parser=str)
    AccountingStorageExternalHost: str | None = parsed_field(parser=str)
    AccountingStorageParameters: str | None = parsed_field(parser=str)
    AccountingStorageTRES: str | None = parsed_field(parser=str)
    AccountingStoreFlags: str | None = parsed_field(parser=str)
    AcctGatherEnergyType: str | None = parsed_field(parser=str)
    AcctGatherFilesystemType: str | None = parsed_field(parser=str)
    AcctGatherInterconnectType: str | None = parsed_field(parser=str)
    AcctGatherNodeFreq: str | None = parsed_field(parser=str)
    AcctGatherProfileType: str | None = parsed_field(parser=str)
    AllowSpecResourcesUsage: str | None = parsed_field(parser=str)
    AuthAltTypes: str | None = parsed_field(parser=str)
    AuthAltParameters: str | None = parsed_field(parser=str)
    BatchStartTimeout: str | None = parsed_field(parser=str)
    BcastExclude: str | None = parsed_field(parser=str)
    BcastParameters: str | None = parsed_field(parser=str)
    BOOT_TIME: str | None = parsed_field(parser=str)
    BurstBufferType: str | None = parsed_field(parser=str)
    CliFilterPlugins: str | None = parsed_field(parser=str)
    CommunicationParameters: str | None = parsed_field(parser=str)
    CompleteWait: str | None = parsed_field(parser=str)
    CoreSpecPlugin: str | None = parsed_field(parser=str)
    CpuFreqDef: str | None = parsed_field(parser=str)
    CpuFreqGovernors: str | None = parsed_field(parser=str)
    CredType: str | None = parsed_field(parser=str)
    DebugFlags: str | None = parsed_field(parser=str)
    DefMemPerNode: str | None = parsed_field(parser=str)
    DependencyParameters: str | None = parsed_field(parser=str)
    DisableRootJobs: str | None = parsed_field(parser=str)
    EioTimeout: str | None = parsed_field(parser=str)
    EnforcePartLimits: str | None = parsed_field(parser=str)
    Epilog: str | None = parsed_field(parser=str)
    EpilogMsgTime: str | None = parsed_field(parser=str)
    EpilogSlurmctld: str | None = parsed_field(parser=str)
    ExtSensorsType: str | None = parsed_field(parser=str)
    ExtSensorsFreq: str | None = parsed_field(parser=str)
    FairShareDampeningFactor: str | None = parsed_field(parser=str)
    FederationParameters: str | None = parsed_field(parser=str)
    FirstJobId: str | None = parsed_field(parser=str)
    GetEnvTimeout: str | None = parsed_field(parser=str)
    GresTypes: str | None = parsed_field(parser=str)
    GpuFreqDef: str | None = parsed_field(parser=str)
    GroupUpdateForce: str | None = parsed_field(parser=str)
    GroupUpdateTime: str | None = parsed_field(parser=str)
    HASH_VAL: str | None = parsed_field(parser=str)
    HealthCheckInterval: str | None = parsed_field(parser=str)
    HealthCheckNodeState: str | None = parsed_field(parser=str)
    HealthCheckProgram: str | None = parsed_field(parser=str)
    InteractiveStepOptions: str | None = parsed_field(parser=str)
    JobAcctGatherParams: str | None = parsed_field(parser=str)
    JobCompHost: str | None = parsed_field(parser=str)
    JobCompLoc: str | None = parsed_field(parser=str)
    JobCompParams: str | None = parsed_field(parser=str)
    JobCompPort: int | None = parsed_field(parser=maybe_int)
    JobCompType: str | None = parsed_field(parser=str)
    JobCompUser: str | None = parsed_field(parser=str)
    JobContainerType: str | None = parsed_field(parser=str)
    JobDefaults: str | None = parsed_field(parser=str)
    JobFileAppend: str | None = parsed_field(parser=str)
    JobRequeue: str | None = parsed_field(parser=str)
    JobSubmitPlugins: str | None = parsed_field(parser=str)
    KillOnBadExit: str | None = parsed_field(parser=str)
    LaunchParameters: str | None = parsed_field(parser=str)
    Licenses: str | None = parsed_field(parser=str)
    LogTimeFormat: str | None = parsed_field(parser=str)
    MailDomain: str | None = parsed_field(parser=str)
    MailProg: str | None = parsed_field(parser=str)
    MaxArraySize: str | None = parsed_field(parser=str)
    MaxBatchRequeue: str | None = parsed_field(parser=str)
    MaxDBDMsgs: str | None = parsed_field(parser=str)
    MaxJobCount: str | None = parsed_field(parser=str)
    MaxJobId: str | None = parsed_field(parser=str)
    MaxMemPerNode: str | None = parsed_field(parser=str)
    MaxNodeCount: str | None = parsed_field(parser=str)
    MaxStepCount: str | None = parsed_field(parser=str)
    MaxTasksPerNode: str | None = parsed_field(parser=str)
    MCSPlugin: str | None = parsed_field(parser=str)
    MCSParameters: str | None = parsed_field(parser=str)
    MessageTimeout: str | None = parsed_field(parser=str)
    MpiDefault: str | None = parsed_field(parser=str)
    MpiParams: str | None = parsed_field(parser=str)
    NEXT_JOB_ID: str | None = parsed_field(parser=str)
    NodeFeaturesPlugins: str | None = parsed_field(parser=str)
    OverTimeLimit: str | None = parsed_field(parser=str)
    PluginDir: str | None = parsed_field(parser=str)
    PlugStackConfig: str | None = parsed_field(parser=str)
    PowerParameters: str | None = parsed_field(parser=str)
    PowerPlugin: str | None = parsed_field(parser=str)
    PreemptMode: str | None = parsed_field(parser=str)
    PreemptParameters: str | None = parsed_field(parser=str)
    PreemptType: str | None = parsed_field(parser=str)
    PreemptExemptTime: str | None = parsed_field(parser=str)
    PrEpParameters: str | None = parsed_field(parser=str)
    PrEpPlugins: str | None = parsed_field(parser=str)
    PriorityParameters: str | None = parsed_field(parser=str)
    PrioritySiteFactorParameters: str | None = parsed_field(parser=str)
    PrioritySiteFactorPlugin: str | None = parsed_field(parser=str)
    PriorityFlags: str | None = parsed_field(parser=str)
    PriorityWeightAssoc: int | None = parsed_field(parser=maybe_int)
    PriorityWeightTRES: str | None = parsed_field(parser=str)
    PrivateData: str | None = parsed_field(parser=str)
    ProctrackType: str | None = parsed_field(parser=str)
    Prolog: str | None = parsed_field(parser=str)
    PrologEpilogTimeout: str | None = parsed_field(parser=str)
    PrologSlurmctld: str | None = parsed_field(parser=str)
    PrologFlags: str | None = parsed_field(parser=str)
    PropagatePrioProcess: str | None = parsed_field(parser=str)
    PropagateResourceLimits: str | None = parsed_field(parser=str)
    PropagateResourceLimitsExcept: str | None = parsed_field(parser=str)
    RebootProgram: str | None = parsed_field(parser=str)
    ReconfigFlags: str | None = parsed_field(parser=str)
    RequeueExit: str | None = parsed_field(parser=str)
    RequeueExitHold: str | None = parsed_field(parser=str)
    ResumeFailProgram: str | None = parsed_field(parser=str)
    ResumeProgram: str | None = parsed_field(parser=str)
    ResumeRate: str | None = parsed_field(parser=str)
    ResumeTimeout: str | None = parsed_field(parser=str)
    ResvEpilog: str | None = parsed_field(parser=str)
    ResvOverRun: str | None = parsed_field(parser=str)
    ResvProlog: str | None = parsed_field(parser=str)
    ReturnToService: str | None = parsed_field(parser=str)
    RoutePlugin: str | None = parsed_field(parser=str)
    SchedulerTimeSlice: str | None = parsed_field(parser=str)
    ScronParameters: str | None = parsed_field(parser=str)
    SlurmctldSyslogDebug: str | None = parsed_field(parser=str)
    SlurmctldPrimaryOffProg: str | None = parsed_field(parser=str)
    SlurmctldPrimaryOnProg: str | None = parsed_field(parser=str)
    SlurmctldParameters: str | None = parsed_field(parser=str)
    SlurmdParameters: str | None = parsed_field(parser=str)
    SlurmdSyslogDebug: str | None = parsed_field(parser=str)
    SlurmSchedLogFile: str | None = parsed_field(parser=str)
    SlurmSchedLogLevel: str | None = parsed_field(parser=str)
    SLURM_CONF: str | None = parsed_field(parser=str)
    SLURM_VERSION: str | None = parsed_field(parser=str)
    SrunEpilog: str | None = parsed_field(parser=str)
    SrunPortRange: str | None = parsed_field(parser=str)
    SrunProlog: str | None = parsed_field(parser=str)
    SuspendExcNodes: str | None = parsed_field(parser=str)
    SuspendExcParts: str | None = parsed_field(parser=str)
    SuspendExcStates: str | None = parsed_field(parser=str)
    SuspendProgram: str | None = parsed_field(parser=str)
    SuspendRate: str | None = parsed_field(parser=str)
    SuspendTime: str | None = parsed_field(parser=str)
    SuspendTimeout: str | None = parsed_field(parser=str)
    SwitchParameters: str | None = parsed_field(parser=str)
    SwitchType: str | None = parsed_field(parser=str)
    TaskEpilog: str | None = parsed_field(parser=str)
    TaskPlugin: str | None = parsed_field(parser=str)
    TaskPluginParam: str | None = parsed_field(parser=str)
    TaskProlog: str | None = parsed_field(parser=str)
    TCPTimeout: str | None = parsed_field(parser=str)
    TmpFS: str | None = parsed_field(parser=str)
    TopologyParam: str | None = parsed_field(parser=str)
    TopologyPlugin: str | None = parsed_field(parser=str)
    TrackWCKey: str | None = parsed_field(parser=str)
    TreeWidth: str | None = parsed_field(parser=str)
    UsePam: str | None = parsed_field(parser=str)
    UnkillableStepProgram: str | None = parsed_field(parser=str)
    UnkillableStepTimeout: str | None = parsed_field(parser=str)
    VSizeFactor: str | None = parsed_field(parser=str)
    WaitTime: str | None = parsed_field(parser=str)
    X11Parameters: str | None = parsed_field(parser=str)
