Implement Domain Model First architecture for JSON-based Slurm command parsing #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements Approach 2 (Domain Model First) for migrating from string parsing to JSON output (
--jsonflag) with clear separation between data retrieval and parsing. Provides complete architecture for future-proofing against multiple data sources (binaries, slurmrestd REST API, files).Current Architecture
internal/slurmapi/BaseProvider[T]with concrete implementations (JobsProvider, NodesProvider, etc.)Implemented Architecture
Five-layer separation of concerns:
Data Sources (
internal/datasource/) -SlurmDataSourceinterface with implementations:BinaryJSONSource- Calls Slurm binaries with--jsonflagFileSource- Reads JSON from files (testing/offline mode)RestAPISource- Placeholder for future slurmrestd supportJSON Parsers (
internal/parser/) - Convert OpenAPI models to domain models:ParseJobsJSON()-V0043OpenapiJobInfoResp→domain.JobsParseNodesJSON()-V0043OpenapiNodesResp→domain.NodesParsePartitionsJSON()-V0043OpenapiPartitionResp→domain.PartitionsDomain Models (
internal/domain/) - API-independent business entities:domain.Job- Comprehensive job representation (40+ fields)domain.Node- Complete compute node modeldomain.Partition- Partition configuration and limitsAdapters (
internal/model/adapters.go) - Transform domain models to display format:JobsToTableData()- Convertsdomain.Jobs→TableDataNodesToTableData()- Convertsdomain.Nodes→TableDataPartitionsToTableData()- Convertsdomain.Partitions→TableDataV2 Providers - Demonstrate the complete pattern:
JobsProviderV2,NodesProviderV2,PartitionsProviderV2Key Benefits
RestAPISourceDocumentation
Complete architecture documentation added in
docs/architecture-json-migration.mdincluding:Testing
Future work: Add unit tests for parsers, integration tests with mock data, gradual V1 to V2 migration.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.