Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Added score to fit_posts (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
spietras committed Aug 25, 2022
1 parent 0632e95 commit 6bf7009
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,24 +367,28 @@ async def generate(

async def fit_posts(
self,
posts: Union[AsyncIterable[Dict[str, Any]], Iterable[Dict[str, Any]]],
posts: Union[
AsyncIterable[Tuple[Dict[str, Any], float]],
Iterable[Tuple[Dict[str, Any], float]],
],
*args,
**kwargs,
) -> None:
async with stream.iterate(posts).stream() as posts:

async def to_requests():
async for post in posts:
async for post, score in posts:
yield FitPostsRequest(
post=RealPost(content=json.dumps(post))
post=RealPost(content=json.dumps(post), score=score)
)

await self._stub.fit_posts(to_requests(), *args, **kwargs)

async def fit_scores(
self,
scores: Union[
AsyncIterable[Tuple[UUID, float]], Iterable[Tuple[UUID, float]]
AsyncIterable[Tuple[UUID, float]],
Iterable[Tuple[UUID, float]],
],
*args,
**kwargs,
Expand Down

0 comments on commit 6bf7009

Please sign in to comment.