-
Notifications
You must be signed in to change notification settings - Fork 689
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
1 parent
a2d4735
commit 462343a
Showing
7 changed files
with
160 additions
and
56 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
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,61 @@ | ||
package artifacts | ||
|
||
import ( | ||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/artifact" | ||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/flyteorg/flytestdlib/logger" | ||
"google.golang.org/grpc" | ||
|
||
"context" | ||
) | ||
|
||
// ArtifactRegistry contains a client to talk to an Artifact service and has helper methods | ||
type ArtifactRegistry struct { | ||
client artifact.ArtifactRegistryClient | ||
} | ||
|
||
func (a *ArtifactRegistry) RegisterArtifactProducer(ctx context.Context, id *core.Identifier, ti core.TypedInterface) { | ||
if a.client == nil { | ||
logger.Debugf(ctx, "Artifact client not configured, skipping registration for task [%+v]", id) | ||
return | ||
} | ||
ap := &artifact.ArtifactProducer{ | ||
EntityId: id, | ||
Outputs: ti.Outputs, | ||
} | ||
_, err := a.client.RegisterProducer(ctx, &artifact.RegisterProducerRequest{ | ||
Producers: []*artifact.ArtifactProducer{ap}, | ||
}) | ||
if err != nil { | ||
logger.Errorf(ctx, "Failed to register artifact producer for task [%+v] with err: %v", id, err) | ||
} | ||
logger.Debugf(ctx, "Registered artifact producer [%+v]", id) | ||
} | ||
|
||
func (a *ArtifactRegistry) RegisterArtifactConsumer(ctx context.Context, id *core.Identifier, pm core.ParameterMap) { | ||
if a.client == nil { | ||
logger.Debugf(ctx, "Artifact client not configured, skipping registration for consumer [%+v]", id) | ||
return | ||
} | ||
ac := &artifact.ArtifactConsumer{ | ||
EntityId: id, | ||
Inputs: &pm, | ||
} | ||
_, err := a.client.RegisterConsumer(ctx, &artifact.RegisterConsumerRequest{ | ||
Consumers: []*artifact.ArtifactConsumer{ac}, | ||
}) | ||
if err != nil { | ||
logger.Errorf(ctx, "Failed to register artifact consumer for entity [%+v] with err: %v", id, err) | ||
} | ||
logger.Debugf(ctx, "Registered artifact consumer [%+v]", id) | ||
} | ||
|
||
func (a *ArtifactRegistry) GetClient() artifact.ArtifactRegistryClient { | ||
return a.client | ||
} | ||
|
||
func NewArtifactRegistry(ctx context.Context, config *Config, opts ...grpc.DialOption) ArtifactRegistry { | ||
return ArtifactRegistry{ | ||
client: InitializeArtifactClient(ctx, config, opts...), | ||
} | ||
} |
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
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.