Skip to content

Commit

Permalink
Services - Metadata Writer - Added support for custom_properties in a…
Browse files Browse the repository at this point in the history
…ll helper methods (#3556)

Fixes #3552
  • Loading branch information
Ark-kun authored Apr 20, 2020
1 parent 152c91c commit 772835f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/metadata_writer/src/metadata_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def create_artifact_with_type(
type_name: str,
properties: dict = None,
type_properties: dict = None,
custom_properties: dict = None,
) -> metadata_store_pb2.Artifact:
artifact_type = get_or_create_artifact_type(
store=store,
Expand All @@ -106,6 +107,7 @@ def create_artifact_with_type(
uri=uri,
type_id=artifact_type.id,
properties=properties,
custom_properties=custom_properties,
)
artifact.id = store.put_artifacts([artifact])[0]
return artifact
Expand All @@ -116,6 +118,7 @@ def create_execution_with_type(
type_name: str,
properties: dict = None,
type_properties: dict = None,
custom_properties: dict = None,
) -> metadata_store_pb2.Execution:
execution_type = get_or_create_execution_type(
store=store,
Expand All @@ -125,6 +128,7 @@ def create_execution_with_type(
execution = metadata_store_pb2.Execution(
type_id=execution_type.id,
properties=properties,
custom_properties=custom_properties,
)
execution.id = store.put_executions([execution])[0]
return execution
Expand All @@ -136,6 +140,7 @@ def create_context_with_type(
type_name: str,
properties: dict = None,
type_properties: dict = None,
custom_properties: dict = None,
) -> metadata_store_pb2.Context:
# ! Context_name must be unique
context_type = get_or_create_context_type(
Expand All @@ -147,6 +152,7 @@ def create_context_with_type(
name=context_name,
type_id=context_type.id,
properties=properties,
custom_properties=custom_properties,
)
context.id = store.put_contexts([context])[0]
return context
Expand All @@ -171,6 +177,7 @@ def get_or_create_context_with_type(
type_name: str,
properties: dict = None,
type_properties: dict = None,
custom_properties: dict = None,
) -> metadata_store_pb2.Context:
try:
context = get_context_by_name(store, context_name)
Expand All @@ -181,6 +188,7 @@ def get_or_create_context_with_type(
type_name=type_name,
properties=properties,
type_properties=type_properties,
custom_properties=custom_properties,
)
return context

Expand All @@ -198,10 +206,12 @@ def create_new_execution_in_existing_context(
context_id: int,
properties: dict = None,
execution_type_properties: dict = None,
custom_properties: dict = None,
) -> metadata_store_pb2.Execution:
execution = create_execution_with_type(
store=store,
properties=properties,
custom_properties=custom_properties,
type_name=execution_type_name,
type_properties=execution_type_properties,
)
Expand Down Expand Up @@ -290,6 +300,7 @@ def create_new_artifact_event_and_attribution(
event_type: metadata_store_pb2.Event.Type,
properties: dict = None,
artifact_type_properties: dict = None,
custom_properties: dict = None,
artifact_name_path: metadata_store_pb2.Event.Path = None,
milliseconds_since_epoch: int = None,
) -> metadata_store_pb2.Artifact:
Expand All @@ -299,6 +310,7 @@ def create_new_artifact_event_and_attribution(
type_name=type_name,
type_properties=artifact_type_properties,
properties=properties,
custom_properties=custom_properties,
)
event = metadata_store_pb2.Event(
execution_id=execution_id,
Expand Down

0 comments on commit 772835f

Please sign in to comment.