Skip to content

Commit

Permalink
Add sync total to collection sync first stage (#1335)
Browse files Browse the repository at this point in the history
fixes: #1219
  • Loading branch information
gerrod3 committed Feb 3, 2023
1 parent 3d4ddb8 commit b33cb33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/1219.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added "total" count on "sync.parsing.metadata" progress report.
12 changes: 11 additions & 1 deletion pulp_ansible/app/tasks/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ async def _fetch_paginated_collection_metadata(self, name, namespace, requiremen
break
page_num = page_num + 1

self.parsing_metadata_progress_bar.total += len(tasks)
await self.parsing_metadata_progress_bar.asave(update_fields=["total"])
await asyncio.gather(*tasks)

async def _read_from_downloaded_metadata(self, name, namespace, requirement):
Expand Down Expand Up @@ -756,6 +758,8 @@ async def _read_from_downloaded_metadata(self, name, namespace, requirement):
)
)
)
self.parsing_metadata_progress_bar.total += len(tasks)
await self.parsing_metadata_progress_bar.asave(update_fields=["total"])
await asyncio.gather(*tasks)

async def _fetch_collection_metadata(self, requirements_entry):
Expand Down Expand Up @@ -867,6 +871,8 @@ async def _find_all_collections_from_unpaginated_data(self):
)
)

self.parsing_metadata_progress_bar.total = len(tasks)
await self.parsing_metadata_progress_bar.asave(update_fields=["total"])
await asyncio.gather(*tasks)

async def _find_all_collections(self):
Expand Down Expand Up @@ -908,6 +914,8 @@ async def _find_all_collections(self):
break
page_num = page_num + 1

self.parsing_metadata_progress_bar.total = len(tasks)
await self.parsing_metadata_progress_bar.asave(update_fields=["total"])
await asyncio.gather(*tasks)

async def _should_we_sync(self):
Expand Down Expand Up @@ -957,7 +965,7 @@ async def run(self):
loop = asyncio.get_event_loop()

msg = _("Parsing CollectionVersion Metadata")
async with ProgressReport(message=msg, code="sync.parsing.metadata") as pb:
async with ProgressReport(message=msg, code="sync.parsing.metadata", total=0) as pb:
self.parsing_metadata_progress_bar = pb
await self._download_unpaginated_metadata()

Expand All @@ -969,6 +977,8 @@ async def run(self):
else:
tasks.append(loop.create_task(self._find_all_collections()))
await asyncio.gather(*tasks)
# Ensure PR 'total' is correct before stage finishes
pb.total = pb.done


class DocsBlobDownloader(ArtifactDownloader):
Expand Down

0 comments on commit b33cb33

Please sign in to comment.