Skip to content

[v3] Refactor metadata classes #1623

Closed
Closed
@normanrz

Description

@normanrz

In the current V3 draft version, all metadata classes are closely modeled after the json representation. For example, the regular chunk grid is represented as this json object:

{
  "name": "regular",
  "configuration": { "chunk_shape": [2, 5] }
}

In Python, these objects are implemented as 2 classes

@frozen
class RegularChunkGridConfigurationMetadata:
    chunk_shape: ChunkCoords


@frozen
class RegularChunkGridMetadata:
    configuration: RegularChunkGridConfigurationMetadata
    name: Literal["regular"] = "regular"

ChunkGridMetadata = Union[RegularChunkGridMetadata]

This is an artifact of using cattrs for (de)serialization. However, we were thinking of dropping the attrs dependency. That would open the way for a more ergonomic class design that serializes to the same json structure.

class ChunkGrid(ABC):
    pass

class RegularChunkGrid(ChunkGrid):
    chunk_shape: ChunkCoords

Metadata

Metadata

Assignees

No one assigned

    Labels

    design discussionhelp wantedIssue could use help from someone with familiarity on the topic

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions