Skip to content

Commit

Permalink
update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
anthayes92 committed Aug 27, 2024
1 parent 1bdd34f commit 2254fa4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pennylane/data/data_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ def _download_full(s3_url: str, dest: Path, block_size: int, pbar_task: Optional


def _get_graphql(url: str, query: str, variables: dict[str, Any] = None):
"""
Args:
url: The URL to send a query to.
query: The main body of the query to be sent.
variables: Additional input variables to the query body.
Returns:
string: json response.
GraphQLError: if there no response is received or errors are received in the json response.
"""

json = {"query": query}

Expand All @@ -137,7 +147,9 @@ def _get_graphql(url: str, query: str, variables: dict[str, Any] = None):
response = get(url=url, json=json, timeout=10)
response.raise_for_status()

if "errors" in response.json():
if response.json() is None:

Check notice on line 150 in pennylane/data/data_manager/__init__.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/data/data_manager/__init__.py#L150

Unnecessary "elif" after "raise", remove the leading "el" from "elif" (no-else-raise)
raise GraphQLError(f"No Response")

Check notice on line 151 in pennylane/data/data_manager/__init__.py

View check run for this annotation

codefactor.io / CodeFactor

pennylane/data/data_manager/__init__.py#L151

Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
elif "errors" in response.json():
all_errors = ",".join(error["message"] for error in response.json()["errors"])
raise GraphQLError(f"Errors in request: {all_errors}")

Expand All @@ -147,8 +159,8 @@ def _get_graphql(url: str, query: str, variables: dict[str, Any] = None):
def _get_dataset_urls(class_id: str, parameters: dict[str, list[str]]) -> list[tuple[str, str]]:
"""
Args:
class_id: Dataset class id ('qchem', 'qspin')
parameters: Dataset parameters ('molname'), etc
class_id: Dataset class id e.g 'qchem', 'qspin'
parameters: Dataset parameters e.g 'molname', 'basis'
Returns:
list of tuples (dataset_id, dataset_url)
Expand Down Expand Up @@ -192,6 +204,8 @@ def _download_dataset( # pylint: disable=too-many-arguments
If any of the attributes of the remote dataset are already downloaded locally,
they will not be overwritten unless ``force`` is True.
If ``pbar_task`` is provided, it will be updated with the download progress.
"""

if attributes is not None or dest.exists():
Expand Down

0 comments on commit 2254fa4

Please sign in to comment.