-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
253 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
artifactsServer: | ||
myTestValue: "test from file" | ||
database: | ||
postgres: | ||
dbname: artifacts | ||
logger: | ||
level: 5 | ||
show-source: true | ||
# This is an (incomplete) configure file for the artifact service, here just as an example. | ||
#artifactsServer: | ||
# database: | ||
# postgres: | ||
# dbname: your pg db | ||
#logger: | ||
# level: 5 | ||
# show-source: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package blob | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/flyteorg/flyte/flyteartifacts/pkg/configuration" | ||
"github.com/flyteorg/flyte/flytestdlib/logger" | ||
"github.com/flyteorg/flyte/flytestdlib/promutils" | ||
"github.com/flyteorg/flyte/flytestdlib/storage" | ||
"github.com/golang/protobuf/ptypes/any" | ||
) | ||
|
||
type ArtifactBlobStore struct { | ||
store *storage.DataStore | ||
} | ||
|
||
// OffloadArtifactCard stores the artifact card in the blob store | ||
func (a *ArtifactBlobStore) OffloadArtifactCard(ctx context.Context, name, version string, card *any.Any) (storage.DataReference, error) { | ||
uri, err := a.store.ConstructReference(ctx, a.store.GetBaseContainerFQN(ctx), name, version) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to construct data reference for [%s/%s] with err: %v", name, version, err) | ||
} | ||
err = a.store.WriteProtobuf(ctx, uri, storage.Options{}, card) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to write protobuf to %s with err: %v", uri, err) | ||
} | ||
return uri, nil | ||
} | ||
|
||
func (a *ArtifactBlobStore) RetrieveArtifactCard(ctx context.Context, uri storage.DataReference) (*any.Any, error) { | ||
card := &any.Any{} | ||
err := a.store.ReadProtobuf(ctx, uri, card) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to read protobuf from %s with err: %v", uri, err) | ||
} | ||
return nil, nil | ||
} | ||
|
||
func NewArtifactBlobStore(ctx context.Context, scope promutils.Scope) ArtifactBlobStore { | ||
storageCfg := configuration.ApplicationConfig.GetConfig().(*configuration.ApplicationConfiguration).ArtifactBlobStoreConfig | ||
logger.Infof(ctx, "Initializing storage client with config [%+v]", storageCfg) | ||
|
||
dataStorageClient, err := storage.NewDataStore(&storageCfg, scope) | ||
if err != nil { | ||
logger.Error(ctx, "Failed to initialize storage config") | ||
panic(err) | ||
} | ||
return ArtifactBlobStore{ | ||
store: dataStorageClient, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package db | ||
|
||
import ( | ||
"github.com/flyteorg/flyte/flyteartifacts/pkg/models" | ||
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/jackc/pgx/v5/pgtype" | ||
) | ||
|
||
func PartitionsIdlToHstore(idlPartitions *core.Partitions) pgtype.Hstore { | ||
if idlPartitions == nil || idlPartitions.GetValue() == nil { | ||
return nil | ||
} | ||
var hstore = make(pgtype.Hstore) | ||
|
||
for k, v := range idlPartitions.GetValue() { | ||
sv := v.GetStaticValue() | ||
hstore[k] = &sv | ||
} | ||
return hstore | ||
} | ||
|
||
func ServiceToGormModel(serviceModel models.Artifact) (Artifact, error) { | ||
partitions := PartitionsIdlToHstore(serviceModel.Artifact.GetArtifactId().GetPartitions()) | ||
|
||
ga := Artifact{ | ||
ArtifactKey: ArtifactKey{ | ||
Project: serviceModel.Artifact.ArtifactId.ArtifactKey.Project, | ||
Domain: serviceModel.Artifact.ArtifactId.ArtifactKey.Domain, | ||
Name: serviceModel.Artifact.ArtifactId.ArtifactKey.Name, | ||
}, | ||
Version: serviceModel.Artifact.ArtifactId.Version, | ||
Partitions: partitions, | ||
|
||
LiteralType: serviceModel.LiteralTypeBytes, | ||
LiteralValue: serviceModel.LiteralValueBytes, | ||
Description: serviceModel.Artifact.Spec.ShortDescription, | ||
MetadataType: serviceModel.Artifact.Spec.MetadataType, | ||
OffloadedUserMetadata: serviceModel.OffloadedMetadata, | ||
|
||
ExecutionName: serviceModel.Artifact.Spec.Execution.Name, | ||
} | ||
|
||
if serviceModel.Artifact.Spec.TaskExecution != nil { | ||
ga.TaskProject = serviceModel.Artifact.Spec.TaskExecution.TaskId.Project | ||
ga.TaskDomain = serviceModel.Artifact.Spec.TaskExecution.TaskId.Domain | ||
ga.TaskName = serviceModel.Artifact.Spec.TaskExecution.TaskId.Name | ||
ga.TaskVersion = serviceModel.Artifact.Spec.TaskExecution.TaskId.Version | ||
ga.RetryAttempt = &serviceModel.Artifact.Spec.TaskExecution.RetryAttempt | ||
} | ||
|
||
return ga, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package models | ||
|
||
import "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/artifact" | ||
|
||
// Artifact is a wrapper object for easier handling of additional fields | ||
type Artifact struct { | ||
artifact.Artifact | ||
OffloadedMetadata string | ||
LiteralTypeBytes []byte | ||
LiteralValueBytes []byte | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.