Skip to content

Commit

Permalink
Merge pull request #168 from kubeagi/bjwswang
Browse files Browse the repository at this point in the history
refactor: definition of versioned dataset
  • Loading branch information
bjwswang authored Nov 2, 2023
2 parents ba42b16 + 11ff7f1 commit f7c9540
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 135 deletions.
27 changes: 26 additions & 1 deletion api/v1alpha1/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type ConditionReason string

// Some common Condition reasons.
const (
ReasonPublished ConditionReason = "Published"
ReasonAvailable ConditionReason = "Available"
ReasonUnavailable ConditionReason = "Unavailable"
ReasonCreating ConditionReason = "Creating"
Expand All @@ -52,6 +51,32 @@ const (
ReasonReconcilePaused ConditionReason = "ReconcilePaused"
)

// Some Data related Condition Types
const (
// Dataset have 3 phases: load -> process -> publish
// TypeLoaded resources are believed to be loaded
TypeLoaded ConditionType = "Loaded"
// TypeProcessed resources are believed to be processed
TypeProcessed ConditionType = "Processed"
// TypePublished resources are believed to be published
TypePublished ConditionType = "Published"
)

// Some Dataset related Condition reasons
const (
// Load data
ReasonDataLoading ConditionReason = "DataLoading"
ReasonDataLoadError ConditionReason = "DataLoadError"
ReasonDataLoadSuccess ConditionReason = "DataLoadSuccess"
// Process data
ReasonDataProcessing ConditionReason = "DataProcessing"
ReasonDataProcessError ConditionReason = "DataProcessError"
ReasonDataProcessSuccess ConditionReason = "DataProcessSuccess"
// Publish dataset
ReasonDatasetUnpublished ConditionReason = "DatasetUnpublished"
ReasonDatasetPublished ConditionReason = "DatasetPublished"
)

// A Condition that may apply to a resource.
type Condition struct {
// Type of this condition. At most one of each condition type may apply to
Expand Down
23 changes: 7 additions & 16 deletions api/v1alpha1/versioneddataset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

type File struct {
type FileGroup struct {
// From defines the datasource which provides this `File`
From *TypedObjectReference `json:"from"`
// Path defines the detail path to get this `File`
Path string `json:"path"`
}

type FileStatus struct {
// UploadCondition records the status of file upload
UploadCondition Condition `json:"uploadCondition,omitempty"`
// ProcessCondition records the status of data processing
ProcessCondition Condition `json:"processCondition,omitempty"`
Datasource *TypedObjectReference `json:"datasource"`
// Paths defines the detail paths to get objects from above datasource
Paths []string `json:"paths"`
}

// VersionedDatasetSpec defines the desired state of VersionedDataset
Expand All @@ -45,17 +38,15 @@ type VersionedDatasetSpec struct {
// Version
Version string `json:"version"`

// Files included in this `VersionedDataset`
Files []File `json:"files,omitempty"`
// FileGroups included in this `VersionedDataset`
// Grouped by Datasource
FileGroups []FileGroup `json:"fileGroups,omitempty"`
}

// VersionedDatasetStatus defines the observed state of VersionedDataset
type VersionedDatasetStatus struct {
// ConditionedStatus is the current status
ConditionedStatus `json:",inline"`

// FilesStatus contains the status to all files in VersionedDatasetSpec
FilesStatus []FileStatus `json:"filesStatus,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
45 changes: 13 additions & 32 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 12 additions & 86 deletions config/crd/bases/arcadia.kubeagi.k8s.com.cn_versioneddatasets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ spec:
- kind
- name
type: object
files:
description: Files included in this `VersionedDataset`
fileGroups:
description: FileGroups included in this `VersionedDataset` Grouped
by Datasource
items:
properties:
from:
datasource:
description: From defines the datasource which provides this
`File`
properties:
Expand All @@ -92,12 +93,15 @@ spec:
- kind
- name
type: object
path:
description: Path defines the detail path to get this `File`
type: string
paths:
description: Paths defines the detail paths to get objects from
above datasource
items:
type: string
type: array
required:
- from
- path
- datasource
- paths
type: object
type: array
version:
Expand Down Expand Up @@ -148,84 +152,6 @@ spec:
- type
type: object
type: array
filesStatus:
description: FilesStatus contains the status to all files in VersionedDatasetSpec
items:
properties:
processCondition:
description: ProcessCondition records the status of data processing
properties:
lastSuccessfulTime:
description: LastSuccessfulTime is repository Last Successful
Update Time
format: date-time
type: string
lastTransitionTime:
description: LastTransitionTime is the last time this condition
transitioned from one status to another.
format: date-time
type: string
message:
description: A Message containing details about this condition's
last transition from one status to another, if any.
type: string
reason:
description: A Reason for this condition's last transition
from one status to another.
type: string
status:
description: Status of this condition; is it currently True,
False, or Unknown
type: string
type:
description: Type of this condition. At most one of each
condition type may apply to a resource at any point in
time.
type: string
required:
- lastTransitionTime
- reason
- status
- type
type: object
uploadCondition:
description: UploadCondition records the status of file upload
properties:
lastSuccessfulTime:
description: LastSuccessfulTime is repository Last Successful
Update Time
format: date-time
type: string
lastTransitionTime:
description: LastTransitionTime is the last time this condition
transitioned from one status to another.
format: date-time
type: string
message:
description: A Message containing details about this condition's
last transition from one status to another, if any.
type: string
reason:
description: A Reason for this condition's last transition
from one status to another.
type: string
status:
description: Status of this condition; is it currently True,
False, or Unknown
type: string
type:
description: Type of this condition. At most one of each
condition type may apply to a resource at any point in
time.
type: string
required:
- lastTransitionTime
- reason
- status
- type
type: object
type: object
type: array
type: object
type: object
served: true
Expand Down

0 comments on commit f7c9540

Please sign in to comment.