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

Commit

Permalink
minor: do not need to resolve process_components with --search-latest…
Browse files Browse the repository at this point in the history
… and --search-provides
  • Loading branch information
JimFuller-RedHat committed Nov 27, 2023
1 parent 83a7f94 commit cc59464
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 42 deletions.
1 change: 0 additions & 1 deletion griffon/commands/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ def get_product_contain_component(
and not search_upstreams
):
ctx.params["search_latest"] = True
ctx.params["search_provides"] = True

params = copy.deepcopy(ctx.params)
params.pop("verbose")
Expand Down
70 changes: 29 additions & 41 deletions griffon/services/core_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,12 @@ def async_retrieve_upstreams(self, purl):

def process_component(session, c):
"""perform any neccessary sub retrievals."""
# we only need to resolve on REDHAT namespace components (for now)
if c.namespace == "REDHAT":
c.sources = async_retrieve_sources(session, c.purl)
c.upstreams = async_retrieve_upstreams(session, c.purl)
# only process provided components
if c.software_build is None:
# we only need to resolve on REDHAT namespace components (for now)
if c.namespace == "REDHAT":
c.sources = async_retrieve_sources(session, c.purl)
c.upstreams = async_retrieve_upstreams(session, c.purl)
return c


Expand Down Expand Up @@ -327,14 +329,10 @@ def execute(self, status=None) -> List[Dict[str, Any]]:
latest_components = self.corgi_session.components.retrieve_list_iterator_async(
**search_latest_params
)
with multiprocessing.Pool() as pool:
status.update(
f"found {latest_components_cnt} latest root component(s), retrieving sources & upstreams." # noqa
)
for processed_component in pool.map(
partial(process_component, self.corgi_session), latest_components
):
results.append(processed_component)
status.update(f"found {latest_components_cnt} latest root component(s).") # noqa
for c in latest_components:
results.append(c)

if not self.no_community:
status.update("searching latest community root component(s).")
community_component_cnt = self.community_session.components.count(
Expand All @@ -348,15 +346,11 @@ def execute(self, status=None) -> List[Dict[str, Any]]:
**search_latest_params
)
)
with multiprocessing.Pool() as pool:
status.update(
f"found {community_component_cnt} latest community root component(s), retrieving sources & upstreams." # noqa
)
for processed_component in pool.map(
partial(process_component, self.community_session),
latest_community_components,
):
results.append(processed_component)
status.update(
f"found {community_component_cnt} latest community root component(s), retrieving sources & upstreams." # noqa
)
for c in latest_community_components:
results.append(c)

if self.search_provides:
search_provides_params = copy.deepcopy(params)
Expand All @@ -368,22 +362,20 @@ def execute(self, status=None) -> List[Dict[str, Any]]:
search_provides_params["namespace"] = self.ns
if not (self.include_inactive_product_streams):
search_provides_params["active_streams"] = "True"
search_provides_params["root_components"] = "True"
search_provides_params["latest_components_by_streams"] = "True"
status.update("searching latest provided child component(s).")
latest_components_cnt = self.corgi_session.components.count(**search_provides_params)
status.update(f"found {latest_components_cnt} latest component(s).")
# latest_components_cnt = self.corgi_session.components.count(**search_provides_params)
latest_components_cnt = 0
status.update(f"found {latest_components_cnt} latest provides component(s).")
latest_components = self.corgi_session.components.retrieve_list_iterator_async(
**search_provides_params
)
with multiprocessing.Pool() as pool:
status.update(
f"found {latest_components_cnt} latest provides child component(s), retrieving sources & upstreams." # noqa
)
for processed_component in pool.map(
partial(process_component, self.corgi_session), latest_components
):
results.append(processed_component)
status.update(
f"found {latest_components_cnt} latest provides child component(s), retrieving sources & upstreams." # noqa
)
for c in latest_components:
results.append(c)

if not self.no_community:
status.update("searching latest community provided child component(s).")
community_component_cnt = self.community_session.components.count(
Expand All @@ -397,15 +389,11 @@ def execute(self, status=None) -> List[Dict[str, Any]]:
**search_provides_params
)
)
with multiprocessing.Pool() as pool:
status.update(
f"found {community_component_cnt} latest community provided child component(s), retrieving sources & upstreams." # noqa
)
for processed_component in pool.map(
partial(process_component, self.community_session),
latest_community_components,
):
results.append(processed_component)
status.update(
f"found {community_component_cnt} latest community provided child component(s), retrieving sources & upstreams." # noqa
)
for c in latest_community_components:
results.append(c)

if self.search_upstreams:
search_upstreams_params = copy.deepcopy(params)
Expand Down

0 comments on commit cc59464

Please sign in to comment.