Skip to content

Commit

Permalink
Removed return_gufe kwarg from AlchemiscaleClient.query_networks (#…
Browse files Browse the repository at this point in the history
…206)

* Removed `return_gufe` kwarg from `AlchemiscaleClient.query_networks`
* Removed `return_gufe` kwarg from `query_networks` in user-facing API

---------

Co-authored-by: David Dotson <[email protected]>
  • Loading branch information
ianmkenney and dotsdl authored Dec 5, 2023
1 parent bf2323d commit 9e7f1e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
10 changes: 5 additions & 5 deletions alchemiscale/interface/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,25 @@ def create_network(
def query_networks(
*,
name: str = None,
return_gufe: bool = False,
scope: Scope = Depends(scope_params),
n4js: Neo4jStore = Depends(get_n4js_depends),
token: TokenData = Depends(get_token_data_depends),
):
# Intersect query scopes with accessible scopes in the token
query_scopes = validate_scopes_query(scope, token)
networks_handler = QueryGUFEHandler(return_gufe)

# query each scope
# loop might be removable in the future with a Union like operator on scopes
results = []
for single_query_scope in query_scopes:
networks_handler.update_results(
results.extend(
n4js.query_networks(
name=name, scope=single_query_scope, return_gufe=return_gufe
name=name,
scope=single_query_scope,
)
)

return networks_handler.format_return()
return [str(sk) for sk in results]


@router.get("/transformations")
Expand Down
16 changes: 3 additions & 13 deletions alchemiscale/interface/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,30 +148,20 @@ def query_networks(
self,
name: Optional[str] = None,
scope: Optional[Scope] = None,
return_gufe=False,
) -> Union[List[ScopedKey], Dict[ScopedKey, AlchemicalNetwork]]:
) -> List[ScopedKey]:
"""Query for AlchemicalNetworks, optionally by name or Scope.
Calling this method with no query arguments will return ScopedKeys for
all AlchemicalNetworks that are within the Scopes this user has access
to.
"""
if return_gufe:
networks = {}
else:
networks = []

if scope is None:
scope = Scope()

params = dict(name=name, return_gufe=return_gufe, **scope.dict())
if return_gufe:
networks.update(self._query_resource("/networks", params=params))
else:
networks.extend(self._query_resource("/networks", params=params))
params = dict(name=name, **scope.dict())

return networks
return self._query_resource("/networks", params=params)

def query_transformations(
self,
Expand Down

0 comments on commit 9e7f1e9

Please sign in to comment.