Skip to content

Commit

Permalink
Add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chanadian committed Sep 10, 2019
1 parent 2404756 commit 876c9a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ admin:
catalog-cache:
type: catalog
endpoint: datacatalog:8089
insecure: true
errors:
show-source: true
logger:
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/catalog/datacatalog/datacatalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type CatalogClient struct {
store storage.ProtobufStore
}

// Helper method to retrieve an artifact by the tag
func (m *CatalogClient) getArtifactByTag(ctx context.Context, tagName string, dataset *datacatalog.Dataset) (*datacatalog.Artifact, error) {
logger.Debugf(ctx, "Get Artifact by tag %v", tagName)
artifactQuery := &datacatalog.GetArtifactRequest{
Expand All @@ -47,6 +48,7 @@ func (m *CatalogClient) getArtifactByTag(ctx context.Context, tagName string, da
return response.Artifact, nil
}

// Helper method to retrieve a dataset that is associated with the task
func (m *CatalogClient) getDataset(ctx context.Context, task *core.TaskTemplate) (*datacatalog.Dataset, error) {
datasetID, err := transformer.GenerateDatasetIDForTask(ctx, task)
if err != nil {
Expand Down Expand Up @@ -174,7 +176,6 @@ func (m *CatalogClient) Put(ctx context.Context, task *core.TaskTemplate, execID
logger.Debugf(ctx, "DataCatalog put into Catalog for DataSet %v", datasetID)

// Try creating the dataset in case it doesn't exist

metadata := &datacatalog.Metadata{
KeyMap: map[string]string{
taskVersionKey: task.Id.Version,
Expand Down Expand Up @@ -250,6 +251,7 @@ func (m *CatalogClient) Put(ctx context.Context, task *core.TaskTemplate, execID
return nil
}

// Create a new Datacatalog client for task execution caching
func NewDataCatalog(ctx context.Context, endpoint string, insecureConnection bool, datastore storage.ProtobufStore) (*CatalogClient, error) {
var opts []grpc.DialOption

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func getDatasetNameFromTask(task *core.TaskTemplate) string {
return fmt.Sprintf("%s-%s", taskNamespace, task.Id.Name)
}

// Transform the artifact Data into task execution outputs as a literal map
func GenerateTaskOutputsFromArtifact(task *core.TaskTemplate, artifact *datacatalog.Artifact) (*core.LiteralMap, error) {

// if there are no outputs in the task, return empty map
if task.Interface.Outputs == nil || len(task.Interface.Outputs.Variables) == 0 {
return &emptyLiteralMap, nil
Expand Down Expand Up @@ -110,6 +112,7 @@ func generateTaskSignatureHash(ctx context.Context, task *core.TaskTemplate) (st
return fmt.Sprintf("%v-%v", inputHashString, outputHashString), nil
}

// Generate a tag by hashing the input values
func GenerateArtifactTagName(ctx context.Context, inputs *core.LiteralMap) (string, error) {
if inputs == nil || len(inputs.Literals) == 0 {
inputs = &emptyLiteralMap
Expand Down

0 comments on commit 876c9a9

Please sign in to comment.