Skip to content

Commit

Permalink
fix(ingest/ruff): added flake8-comprehensions to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-salvi-apptware committed Jan 20, 2025
1 parent aff5e16 commit a29183c
Show file tree
Hide file tree
Showing 699 changed files with 13,432 additions and 7,876 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def report_operation(context):
for outlet in task._outlets:
print(f"Reporting insert operation for {outlet.urn}")
reporter.report_operation(
urn=outlet.urn, operation_type="INSERT", num_affected_rows=123
urn=outlet.urn,
operation_type="INSERT",
num_affected_rows=123,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
task_id="pet_profiles_operation_sensor",
datahub_rest_conn_id="datahub_longtail",
urn=[
"urn:li:dataset:(urn:li:dataPlatform:snowflake,long_tail_companions.adoption.pet_profiles,PROD)"
"urn:li:dataset:(urn:li:dataPlatform:snowflake,long_tail_companions.adoption.pet_profiles,PROD)",
],
time_delta=datetime.timedelta(minutes=10),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
task_id="pet_profiles_operation_sensor",
datahub_rest_conn_id="datahub_longtail",
urn=[
"urn:li:dataset:(urn:li:dataPlatform:snowflake,long_tail_companions.adoption.pet_profiles,PROD)"
"urn:li:dataset:(urn:li:dataPlatform:snowflake,long_tail_companions.adoption.pet_profiles,PROD)",
],
time_delta=datetime.timedelta(days=1),
)
Expand All @@ -36,7 +36,7 @@
task_id="pet_profiles_assertion_circuit_breaker",
datahub_rest_conn_id="datahub_longtail",
urn=[
"urn:li:dataset:(urn:li:dataPlatform:snowflake,long_tail_companions.adoption.pet_profiles,PROD)"
"urn:li:dataset:(urn:li:dataPlatform:snowflake,long_tail_companions.adoption.pet_profiles,PROD)",
],
check_last_assertion_time=True,
)
Expand Down
20 changes: 10 additions & 10 deletions metadata-ingestion/examples/demo_data/enrich.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def create_owner_entity_mce(owner: str) -> MetadataChangeEventClass:
displayName=owner,
fullName=owner,
email=f"{clean_name}[email protected]",
)
),
],
)
),
)


Expand All @@ -111,9 +111,9 @@ def create_ownership_aspect_mce(directive: Directive) -> MetadataChangeEventClas
time=int(time.time() * 1000),
actor="urn:li:corpuser:datahub",
),
)
),
],
)
),
)


Expand All @@ -133,10 +133,10 @@ def create_lineage_aspect_mce(directive: Directive) -> MetadataChangeEventClass:
),
)
for upstream in directive.depends_on
]
)
],
),
],
)
),
)


Expand All @@ -145,7 +145,7 @@ def create_global_tags_aspect_mce(directive: Directive) -> MetadataChangeEventCl
proposedSnapshot=DatasetSnapshotClass(
urn=dataset_name_to_urn(directive.table),
aspects=[GlobalTagsClass(tags=[])],
)
),
)


Expand All @@ -166,9 +166,9 @@ def create_editable_schema_info_aspect_mce(
actor="urn:li:corpuser:datahub",
),
editableSchemaFieldInfo=[],
)
),
],
)
),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@
emitter = DatahubRestEmitter(gms_server=gms_endpoint, extra_headers={})

feature_table_urn = builder.make_ml_feature_table_urn(
feature_table_name="my-feature-table", platform="feast"
feature_table_name="my-feature-table",
platform="feast",
)
feature_urns = [
builder.make_ml_feature_urn(
feature_name="my-feature2", feature_table_name="my-feature-table"
feature_name="my-feature2",
feature_table_name="my-feature-table",
),
]

# This code concatenates the new features with the existing features in the feature table.
# If you want to replace all existing features with only the new ones, you can comment out this line.
graph = DataHubGraph(DatahubClientConfig(server=gms_endpoint))
feature_table_properties = graph.get_aspect(
entity_urn=feature_table_urn, aspect_type=MLFeatureTablePropertiesClass
entity_urn=feature_table_urn,
aspect_type=MLFeatureTablePropertiesClass,
)
if feature_table_properties:
current_features = feature_table_properties.mlFeatures
Expand Down
10 changes: 7 additions & 3 deletions metadata-ingestion/examples/library/add_mlfeature_to_mlmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@
emitter = DatahubRestEmitter(gms_server=gms_endpoint, extra_headers={})

model_urn = builder.make_ml_model_urn(
model_name="my-test-model", platform="science", env="PROD"
model_name="my-test-model",
platform="science",
env="PROD",
)
feature_urns = [
builder.make_ml_feature_urn(
feature_name="my-feature3", feature_table_name="my-feature-table"
feature_name="my-feature3",
feature_table_name="my-feature-table",
),
]

# This code concatenates the new features with the existing features in the model
# If you want to replace all existing features with only the new ones, you can comment out this line.
graph = DataHubGraph(DatahubClientConfig(server=gms_endpoint))
model_properties = graph.get_aspect(
entity_urn=model_urn, aspect_type=MLModelPropertiesClass
entity_urn=model_urn,
aspect_type=MLModelPropertiesClass,
)
if model_properties:
current_features = model_properties.mlFeatures
Expand Down
13 changes: 9 additions & 4 deletions metadata-ingestion/examples/library/add_mlgroup_to_mlmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@

model_group_urns = [
builder.make_ml_model_group_urn(
group_name="my-model-group", platform="science", env="PROD"
)
group_name="my-model-group",
platform="science",
env="PROD",
),
]
model_urn = builder.make_ml_model_urn(
model_name="science-model", platform="science", env="PROD"
model_name="science-model",
platform="science",
env="PROD",
)

# This code concatenates the new features with the existing features in the feature table.
# If you want to replace all existing features with only the new ones, you can comment out this line.
graph = DataHubGraph(DatahubClientConfig(server=gms_endpoint))

target_model_properties = graph.get_aspect(
entity_urn=model_urn, aspect_type=models.MLModelPropertiesClass
entity_urn=model_urn,
aspect_type=models.MLModelPropertiesClass,
)
if target_model_properties:
current_model_groups = target_model_properties.groups
Expand Down
3 changes: 2 additions & 1 deletion metadata-ingestion/examples/library/create_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

domain_urn = make_domain_urn("marketing")
domain_properties_aspect = DomainPropertiesClass(
name="Marketing", description="Entities related to the marketing department"
name="Marketing",
description="Entities related to the marketing department",
)

event: MetadataChangeProposalWrapper = MetadataChangeProposalWrapper(
Expand Down
4 changes: 2 additions & 2 deletions metadata-ingestion/examples/library/create_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
title="First Prompt",
type=FormPromptTypeClass.STRUCTURED_PROPERTY, # structured property type prompt
structuredPropertyParams=StructuredPropertyParamsClass(
urn="urn:li:structuredProperty:property1"
urn="urn:li:structuredProperty:property1",
), # reference existing structured property
required=True,
)
Expand All @@ -32,7 +32,7 @@
title="Second Prompt",
type=FormPromptTypeClass.FIELDS_STRUCTURED_PROPERTY, # structured property prompt on dataset schema fields
structuredPropertyParams=StructuredPropertyParamsClass(
urn="urn:li:structuredProperty:property1"
urn="urn:li:structuredProperty:property1",
),
required=False, # dataset schema fields prompts should not be required
)
Expand Down
4 changes: 3 additions & 1 deletion metadata-ingestion/examples/library/create_mlfeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
emitter = DatahubRestEmitter(gms_server="http://localhost:8080", extra_headers={})

dataset_urn = builder.make_dataset_urn(
name="fct_users_created", platform="hive", env="PROD"
name="fct_users_created",
platform="hive",
env="PROD",
)
feature_urn = builder.make_ml_feature_urn(
feature_table_name="users_feature_table",
Expand Down
11 changes: 7 additions & 4 deletions metadata-ingestion/examples/library/create_mlfeature_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@
emitter = DatahubRestEmitter(gms_server="http://localhost:8080", extra_headers={})

feature_table_urn = builder.make_ml_feature_table_urn(
feature_table_name="users_feature_table", platform="feast"
feature_table_name="users_feature_table",
platform="feast",
)

feature_urns = [
builder.make_ml_feature_urn(
feature_name="user_signup_date", feature_table_name="users_feature_table"
feature_name="user_signup_date",
feature_table_name="users_feature_table",
),
builder.make_ml_feature_urn(
feature_name="user_last_active_date", feature_table_name="users_feature_table"
feature_name="user_last_active_date",
feature_table_name="users_feature_table",
),
]

primary_key_urns = [
builder.make_ml_primary_key_urn(
feature_table_name="users_feature_table",
primary_key_name="user_id",
)
),
]

feature_table_properties = models.MLFeatureTablePropertiesClass(
Expand Down
28 changes: 19 additions & 9 deletions metadata-ingestion/examples/library/create_mlmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@
# Create an emitter to DataHub over REST
emitter = DatahubRestEmitter(gms_server="http://localhost:8080", extra_headers={})
model_urn = builder.make_ml_model_urn(
model_name="my-recommendations-model-run-1", platform="science", env="PROD"
model_name="my-recommendations-model-run-1",
platform="science",
env="PROD",
)
model_group_urns = [
builder.make_ml_model_group_urn(
group_name="my-recommendations-model-group", platform="science", env="PROD"
)
group_name="my-recommendations-model-group",
platform="science",
env="PROD",
),
]
feature_urns = [
builder.make_ml_feature_urn(
feature_name="user_signup_date", feature_table_name="users_feature_table"
feature_name="user_signup_date",
feature_table_name="users_feature_table",
),
builder.make_ml_feature_urn(
feature_name="user_last_active_date", feature_table_name="users_feature_table"
feature_name="user_last_active_date",
feature_table_name="users_feature_table",
),
]

Expand All @@ -33,13 +39,17 @@
mlFeatures=feature_urns,
trainingMetrics=[
models.MLMetricClass(
name="accuracy", description="accuracy of the model", value="1.0"
)
name="accuracy",
description="accuracy of the model",
value="1.0",
),
],
hyperParams=[
models.MLHyperParamClass(
name="hyper_1", description="hyper_1", value="0.102"
)
name="hyper_1",
description="hyper_1",
value="0.102",
),
],
),
)
Expand Down
4 changes: 3 additions & 1 deletion metadata-ingestion/examples/library/create_mlmodel_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
# Create an emitter to DataHub over REST
emitter = DatahubRestEmitter(gms_server="http://localhost:8080", extra_headers={})
model_group_urn = builder.make_ml_model_group_urn(
group_name="my-recommendations-model-group", platform="science", env="PROD"
group_name="my-recommendations-model-group",
platform="science",
env="PROD",
)


Expand Down
4 changes: 3 additions & 1 deletion metadata-ingestion/examples/library/create_mlprimarykey.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
emitter = DatahubRestEmitter(gms_server="http://localhost:8080", extra_headers={})

dataset_urn = builder.make_dataset_urn(
name="fct_users_created", platform="hive", env="PROD"
name="fct_users_created",
platform="hive",
env="PROD",
)
primary_key_urn = builder.make_ml_primary_key_urn(
feature_table_name="users_feature_table",
Expand Down
Loading

0 comments on commit a29183c

Please sign in to comment.