Skip to content

Commit

Permalink
rework description
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmachan committed Sep 24, 2024
1 parent 611212a commit 85b0256
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/ragas/experimental/testset/transforms/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ async def run_coroutines(coroutines: t.List[t.Coroutine], desc: str, max_workers
logger.error(f"unable to apply transformation: {e}")


def get_desc(transform: BaseGraphTransformations | Parallel):
if isinstance(transform, Parallel):
transform_names = [t.__class__.__name__ for t in transform.transformations]
return f"Applying [{', '.join(transform_names)}] transformations in parallel"
else:
return f"Applying {transform.__class__.__name__}"


@dataclass
class TransformerEngine:
_nest_asyncio_applied: bool = False
Expand Down Expand Up @@ -74,25 +82,19 @@ def apply(
# if Sequences, apply each transformation sequentially
if isinstance(transforms, t.List):
for transform in transforms:
desc = f"Applying {transform.__class__.__name__}"
asyncio.run(
run_coroutines(
transform.generate_execution_plan(kg),
desc,
get_desc(transform),
run_config.max_workers,
)
)
# if Parallel, collect inside it and run it all
elif isinstance(transforms, Parallel):
transform_names = [t.__class__.__name__ for t in transforms.transformations]
print("names:", transform_names)
desc = (
f"Applying [{', '.join(transform_names)}] transformations in parallel"
)
asyncio.run(
run_coroutines(
transforms.generate_execution_plan(kg),
desc,
get_desc(transforms),
run_config.max_workers,
)
)
Expand Down

0 comments on commit 85b0256

Please sign in to comment.