GitHub user bobbai00 created a discussion: Proposal: Unified Data Model For Texera Resources
## Existing Data Model As illustrated in #9394 , today's Texera's resource management are scattered and ad-hoc. This reflects in Texera's current relational model <img width="3604" height="1816" alt="figure-1-existing-model" src="https://github.com/user-attachments/assets/dcfd6748-9d9f-4b89-adfc-3ad4df82c0b5" /> This model has three limitations: 1. **Duplicated resource definition**: each of the seven kinds has its own identifier, such as `wid`, `did`, and `mid`, and repeats the attributes they all share, such as the name. A new kind has to repeat them again. 2. **Scattered resource access control**: `own` and `access` are defined once per kind, which gives ten relationships for two ideas. They also differ by kind: a warehouse and an environment cannot be shared, and an execution has neither. 3. **Incomplete resource lineage**: only an execution records lineage, through four relationships. Nothing records which dataset versions a workflow version reads, which ones an execution produces, or which environment it used. Part 1 addresses the first two limitations, and Parts 2 and 3 address the third. ## Part 1: Unified Resource And Resource Access ### Unified Resource Today each kind of resource, such as a workflow, a dataset, or a computing unit, is its own entity, with its own identifier and its own relationships to `User`. I propose one supertype, `Resource`, and making every kind a subtype of it through an ISA relationship. `Resource` holds what all kinds share, starting with one identifier, `rid`, and each kind keeps only the attributes and relationships that are specific to it. For example, here is what `Resource` keeps and what each kind keeps: 1. **Resource**: keeps what every kind has, which is `rid`, `kind`, `name`, `description`, and `creation time`. 2. **Workflow**: keeps its `content`, which is the operators and links on its canvas. 3. **Dataset**: keeps its `repository`, which is where its files are stored. 4. **Model**: keeps its `framework`, such as PyTorch. 5. **Computing Unit**: keeps its `type`, such as Kubernetes, and its `uri`, which is its address. 6. **Warehouse**: keeps its `bucket`, which is where the results of executions are stored. 7. **Environment**: keeps its `packages`, which are the Python packages it installs. 8. **Execution**: keeps its `status`, such as running or completed. <img width="2800" height="1328" alt="figure-2-unified-resource" src="https://github.com/user-attachments/assets/9605c164-262a-4864-9bc1-f3e2a1f8896c" /> So the workflow "Iris classifier" has its name, description, and creation time in `Resource`, and its content in `Workflow`. The attributes listed for each kind are representative ones, not all of them. I think this has two benefits: 1. **Shared parts are modeled once**: an attribute or a relationship defined on `Resource`, such as the name or access, applies to every kind through inheritance. 2. **A new kind is cheap to add**: it is one more entity under `Resource`, and it inherits everything `Resource` already has. ### Resource Access Access is modeled between `User` and `Resource`, so every kind inherits it. I see two alternative designs. Both keep `created by` as its own relationship, which records the user who created the resource. They differ in whether `own` is also its own relationship or a level of `access`. #### Design A: Separate Own And Access In this design `User` and `Resource` have three relationships: 1. **created by**: every resource is created by exactly one user. 2. **own**: every resource is owned by exactly one user. 3. **access**: a resource is shared with any number of users, each at the level read or write. <img width="2800" height="1220" alt="figure-3-design-a" src="https://github.com/user-attachments/assets/17925d6f-4375-4378-9ecd-b0743baa0a28" /> #### Design B: Own As A Level Of Access In this design `own` and `access` are combined into one `access` relationship with three levels, and `created by` stays as it is in Design A: 1. **created by**: every resource is created by exactly one user. 2. **access**: a resource is accessed by any number of users, each at the level own, read, or write. <img width="2800" height="940" alt="figure-4-design-b" src="https://github.com/user-attachments/assets/d7ec7bab-f499-4b55-8a91-fcda42f248fc" /> #### Recommendation I prefer Design A, for two reasons: 1. **It is semantically more accurate**: owning a resource is a different relationship from having access to it, so `own` is its own relationship rather than a level of `access`. 2. **It constrains ownership by cardinality**: `own` is many-to-one, and every resource takes part in it, so the database can enforce that every resource has exactly one owner. In Design B, that is a rule kept outside the model. ## Part 2: Versions And Version Access Three kinds of resources have versions today: workflows, datasets, and models. I propose adding environments as a fourth, and giving each of the four its own version entity, so a `Workflow` has `Workflow Version`s, a `Dataset` has `Dataset Version`s, a `Model` has `Model Version`s, and an `Environment` has `Environment Version`s. Every version belongs to exactly one resource. The other kinds, such as computing units, have no version entity. I propose modeling each version entity as a weak entity. A version has no identifier of its own: it is identified by the `rid` of the resource it belongs to, together with its own version number, `vno`. For example, the third version of workflow 7 is identified by `rid` 7 and `vno` 3. In the diagram below, a double border marks a weak entity and the relationship that identifies it, and a dashed underline marks its partial key. Access to a version comes from its resource. As in Part 1, `access` is only between `User` and `Resource`, and a version has no access of its own. For example, a user who can read the dataset "Iris flowers" can read every version of it, including versions added later. <img width="2800" height="1568" alt="figure-5-versions-and-access" src="https://github.com/user-attachments/assets/95f15422-41f5-46ea-9453-5536bf4d7ce5" /> ## Part 3: Lineage Lineage records how resources and their versions depend on each other, and who started each execution. I propose modeling each kind of dependency as its own relationship: 1. **reads**: a workflow version reads the dataset versions it takes as input. 2. **executes**: an execution executes exactly one workflow version. 3. **starts**: a user starts an execution, and every execution is started by exactly one user. 4. **hosts**: a computing unit hosts the executions that run on it. 5. **uses**: an execution uses the environment versions that its Python UDF operators run in. 6. **stores**: a warehouse stores the results of the executions that write to it. 7. **exports**: an execution exports the dataset versions it produces. <img width="2800" height="2072" alt="figure-6-lineage" src="https://github.com/user-attachments/assets/2d9c539b-d177-4b71-a599-c3b5d3544e0d" /> As a result, a dataset version can be traced back to the execution that exported it, and from there to the workflow version it executed, the dataset versions that workflow version read, the user who started it, the computing unit that hosted it, the environment versions it used, and the warehouse that stores its results. The diagram shows these seven relationships; other pairs, such as an execution exporting a model version, are added the same way. Access works as in Parts 1 and 2 and is left out of the diagram. GitHub link: https://github.com/apache/texera/discussions/9690 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
