-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Setup basic verb test runner * Replace join_text_units_to_entity_ids with subflow * Update comments * Replace join_text_units_to_relationship_ids subflow * Roll in final select * Reuse assertion util * Small fix + format * Format/typing * Semver * Format/typing * Semver * Revert format changes * Fix smoke test subworkflow count * Edit subworkflows for another smoke test * Update test parquets for covariates * Collapse covariate join * Rework subtasks for per-flow customization * Format * Semver * Fix smoke test
- Loading branch information
Showing
23 changed files
with
126 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type": "patch", | ||
"description": "Covariate verb collapse." | ||
} |
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
27 changes: 27 additions & 0 deletions
27
graphrag/index/workflows/v1/subflows/join_text_units_to_covariate_ids.py
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,27 @@ | ||
# Copyright (c) 2024 Microsoft Corporation. | ||
# Licensed under the MIT License | ||
|
||
"""join_text_units_to_covariate_ids verb (subtask).""" | ||
|
||
from typing import Any, cast | ||
|
||
from datashaper.engine.verbs.verb_input import VerbInput | ||
from datashaper.engine.verbs.verbs_mapping import verb | ||
from datashaper.table_store.types import Table, VerbResult, create_verb_result | ||
|
||
from graphrag.index.verbs.overrides.aggregate import aggregate_df | ||
|
||
|
||
@verb(name="join_text_units_to_covariate_ids", treats_input_tables_as_immutable=True) | ||
def join_text_units_to_covariate_ids( | ||
input: VerbInput, | ||
select_columns: list[str], | ||
aggregate_aggregations: list[dict[str, Any]], | ||
aggregate_groupby: list[str] | None = None, | ||
**_kwargs: dict, | ||
) -> VerbResult: | ||
"""Subtask to select and unroll items using an id.""" | ||
table = input.get_input() | ||
selected = cast(Table, table[select_columns]) | ||
aggregated = aggregate_df(selected, aggregate_aggregations, aggregate_groupby) | ||
return create_verb_result(aggregated) |
29 changes: 29 additions & 0 deletions
29
graphrag/index/workflows/v1/subflows/join_text_units_to_entity_ids.py
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,29 @@ | ||
# Copyright (c) 2024 Microsoft Corporation. | ||
# Licensed under the MIT License | ||
|
||
"""join_text_units_to_entity_ids verb (subtask).""" | ||
|
||
from typing import Any, cast | ||
|
||
from datashaper.engine.verbs.verb_input import VerbInput | ||
from datashaper.engine.verbs.verbs_mapping import verb | ||
from datashaper.table_store.types import Table, VerbResult, create_verb_result | ||
|
||
from graphrag.index.verbs.overrides.aggregate import aggregate_df | ||
|
||
|
||
@verb(name="join_text_units_to_entity_ids", treats_input_tables_as_immutable=True) | ||
def join_text_units_to_entity_ids( | ||
input: VerbInput, | ||
select_columns: list[str], | ||
unroll_column: str, | ||
aggregate_aggregations: list[dict[str, Any]], | ||
aggregate_groupby: list[str] | None = None, | ||
**_kwargs: dict, | ||
) -> VerbResult: | ||
"""Subtask to select and unroll items using an id.""" | ||
table = input.get_input() | ||
selected = cast(Table, table[select_columns]) | ||
unrolled = selected.explode(unroll_column).reset_index(drop=True) | ||
aggregated = aggregate_df(unrolled, aggregate_aggregations, aggregate_groupby) | ||
return create_verb_result(aggregated) |
30 changes: 30 additions & 0 deletions
30
graphrag/index/workflows/v1/subflows/join_text_units_to_relationship_ids.py
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,30 @@ | ||
# Copyright (c) 2024 Microsoft Corporation. | ||
# Licensed under the MIT License | ||
|
||
"""join_text_units_to_relationship_ids verb (subtask).""" | ||
|
||
from typing import Any, cast | ||
|
||
from datashaper.engine.verbs.verb_input import VerbInput | ||
from datashaper.engine.verbs.verbs_mapping import verb | ||
from datashaper.table_store.types import Table, VerbResult, create_verb_result | ||
|
||
from graphrag.index.verbs.overrides.aggregate import aggregate_df | ||
|
||
|
||
@verb(name="join_text_units_to_relationship_ids", treats_input_tables_as_immutable=True) | ||
def join_text_units_to_relationship_ids( | ||
input: VerbInput, | ||
select_columns: list[str], | ||
unroll_column: str, | ||
aggregate_aggregations: list[dict[str, Any]], | ||
aggregate_groupby: list[str] | None = None, | ||
final_select_columns: list[str] | None = None, | ||
**_kwargs: dict, | ||
) -> VerbResult: | ||
"""Subtask to select and unroll items using an id.""" | ||
table = input.get_input() | ||
selected = cast(Table, table[select_columns]) | ||
unrolled = selected.explode(unroll_column).reset_index(drop=True) | ||
aggregated = aggregate_df(unrolled, aggregate_aggregations, aggregate_groupby) | ||
return create_verb_result(cast(Table, aggregated[final_select_columns])) |
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 |
---|---|---|
|
@@ -50,7 +50,7 @@ | |
1, | ||
2000 | ||
], | ||
"subworkflows": 2, | ||
"subworkflows": 1, | ||
"max_runtime": 10 | ||
}, | ||
"create_base_entity_graph": { | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-160 Bytes
(99%)
tests/verbs/data/join_text_units_to_relationship_ids.parquet
Binary file not shown.
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,22 @@ | ||
# Copyright (c) 2024 Microsoft Corporation. | ||
# Licensed under the MIT License | ||
|
||
from graphrag.index.workflows.v1.join_text_units_to_covariate_ids import build_steps | ||
|
||
from .util import compare_outputs, get_workflow_output, load_expected, load_input_tables | ||
|
||
|
||
async def test_join_text_units_to_covariate_ids(): | ||
input_tables = load_input_tables([ | ||
"workflow:create_final_covariates", | ||
]) | ||
expected = load_expected("join_text_units_to_covariate_ids") | ||
|
||
actual = await get_workflow_output( | ||
input_tables, | ||
{ | ||
"steps": build_steps({}), | ||
}, | ||
) | ||
|
||
compare_outputs(actual, expected) |