Skip to content

Commit

Permalink
No-op.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 586082020
  • Loading branch information
ml-metadata-team authored and tfx-copybara committed Nov 28, 2023
1 parent f0fef74 commit 8276e99
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ml_metadata/proto/metadata_store.proto
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ message Association {
message ParentContext {
optional int64 child_id = 1;
optional int64 parent_id = 2;

// Output only.
optional google.protobuf.Any system_metadata = 3;
}

// A self-contained provenance (sub)graph representation consists of MLMD nodes
Expand Down
8 changes: 8 additions & 0 deletions ml_metadata/util/record_parsing_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ absl::Status ParseRecordSetToEdgeArray(
CustomColumnParser());
}

absl::Status ParseRecordSetToEdgeArray(
const RecordSet& record_set,
std::vector<ParentContext>& output_parent_contexts,
const CustomColumnParser& parser) {
return ParseRecordSetToMessageArray(record_set, output_parent_contexts,
parser);
}

absl::Status ParseNodeRecordSetToDedupedTypes(
const RecordSet& node_record_set,
std::vector<ArtifactType>& output_artifact_types,
Expand Down
8 changes: 8 additions & 0 deletions ml_metadata/util/record_parsing_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ absl::Status ParseRecordSetToEdgeArray(
absl::Status ParseRecordSetToEdgeArray(
const RecordSet& record_set, std::vector<Attribution>& output_attributions);

// Converts `record_set` to a ParentContext array.
// Returns OK and the parsed result is outputted by `output_parent_contexts`.
// Returns error when internal error happens.
absl::Status ParseRecordSetToEdgeArray(
const RecordSet& record_set,
std::vector<ParentContext>& output_parent_contexts,
const CustomColumnParser& parser = CustomColumnParser());

// Extracts ArtifactType information from `node_record_set` to a deduped
// ArtifactType array.
// Returns OK and the parsed result is outputted by `output_artifact_types`.
Expand Down
36 changes: 36 additions & 0 deletions ml_metadata/util/record_parsing_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace {
using ::ml_metadata::testing::EqualsProto;
using ::ml_metadata::testing::ParseTextProtoOrDie;
using ::testing::ElementsAre;
using ::testing::IsEmpty;

TEST(ParseRecordSetTest, ParseRecordSetToArtifactArraySuccess) {
RecordSet record_set = ParseTextProtoOrDie<RecordSet>(
Expand Down Expand Up @@ -273,6 +274,40 @@ TEST(ParseRecordSetTest, ParseRecordSetToAttributionArraySuccess) {
)pb"))));
}

TEST(ParseRecordSetTest, ParseRecordSetToParentContextArraySuccess) {
RecordSet record_set = ParseTextProtoOrDie<RecordSet>(
R"pb(
column_names: 'parent_id'
column_names: 'child_id'
records { values: '123' values: '321' }
records { values: '456' values: '654' }
)pb");

std::vector<ParentContext> parent_contexts;
absl::Status status = ParseRecordSetToEdgeArray(record_set, parent_contexts);
EXPECT_EQ(status, absl::OkStatus());
EXPECT_THAT(parent_contexts,
ElementsAre(EqualsProto(ParseTextProtoOrDie<ParentContext>(R"pb(
parent_id: 123 child_id: 321
)pb")),
EqualsProto(ParseTextProtoOrDie<ParentContext>(R"pb(
parent_id: 456 child_id: 654
)pb"))));
}

TEST(ParseRecordSetTest, ParseRecordSetToParentContextArrayEmptySuccess) {
RecordSet record_set = ParseTextProtoOrDie<RecordSet>(
R"pb(
column_names: 'parent_id'
column_names: 'child_id'
)pb");

std::vector<ParentContext> parent_contexts;
absl::Status status = ParseRecordSetToEdgeArray(record_set, parent_contexts);
EXPECT_EQ(status, absl::OkStatus());
EXPECT_THAT(parent_contexts, IsEmpty());
}

TEST(ParseRecordSetTest, MismatchRecordAndFieldNameIgnored) {
RecordSet record_set = ParseTextProtoOrDie<RecordSet>(
R"pb(
Expand Down Expand Up @@ -457,6 +492,7 @@ TEST(ParseRecordSetTest, ParseRecordSetToDedupedContextTypeArraySuccess) {
name: 'context_type_1'
)pb"))));
}

} // namespace
} // namespace testing
} // namespace ml_metadata

0 comments on commit 8276e99

Please sign in to comment.