Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poetry draft #319

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .harness/pythonsdkpublish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inputSet:
value: <+input>
- name: ruff
type: String
value: <+input>
value: ruff format --check indico tests
- name: mypy
type: String
value: <+input>
Expand Down
2 changes: 1 addition & 1 deletion .harness/pythonsdkrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inputSet:
value: <+input>
- name: ruff
type: String
value: <+input>
value: ruff format --check indico tests
- name: mypy
type: String
value: <+input>
Expand Down
11 changes: 3 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ repos:
exclude: ^docs
- id: trailing-whitespace
exclude: ^docs
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
- id: ruff-format
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
FROM python:3.10.4
ARG REGISTRY_PATH='harbor.devops.indico.io/indico'
ARG BUILD_TAG=latest

ENV INDICO_HOST="try.indico.io"
FROM ${REGISTRY_PATH}/ubuntu-2204-build:${BUILD_TAG} as poetry-installer
ARG POETRY_INSTALL_ARGS

RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -yqq apt-transport-https

#deadsnakes holds old versions of python for ubuntu
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yqq software-properties-common && add-apt-repository ppa:deadsnakes/ppa

RUN DEBIAN_FRONTEND=noninteractive apt-get -yqq install python3.8 python3.9 python3.10 python3.11 python3.12 python3.13 python3-pip

RUN pip3 install tox==4.11.3

COPY . /indico-client
WORKDIR /indico-client
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

20 changes: 9 additions & 11 deletions indico/client/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from enum import Enum
from typing import TYPE_CHECKING, Generic, TypeVar, cast

import jq

from indico.errors import IndicoInputError, IndicoRequestError
from indico.typing import AnyDict

Expand Down Expand Up @@ -100,20 +102,16 @@ def __init__(self, query: str, variables: "Optional[AnyDict]" = None):
super().__init__(query, variables=variables)

def process_response(
self, response: "AnyDict", nested_keys: "Optional[List[str]]" = None
self, response: "AnyDict", jq_path: "Optional[str]" = None
) -> "Any":
raw_response: "AnyDict" = cast("AnyDict", super().process_response(response))
if nested_keys:
_pg = raw_response
for key in nested_keys:
if key not in _pg.keys():
raise IndicoInputError(
f"Nested key not found in response: {key}",
)
_pg = _pg[key]
_pg = _pg["pageInfo"]
if jq_path:
try:
_pg = jq.compile(jq_path).input(raw_response).first()["pageInfo"]
except Exception:
raise IndicoInputError(f"Invalid jq path: {jq_path}. ")
else:
_pg = next(iter(response.values()))["pageInfo"]
_pg = raw_response["pageInfo"]

if not _pg:
raise ValueError("The supplied GraphQL must include 'pageInfo'.")
Expand Down
8 changes: 4 additions & 4 deletions indico/filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ class ComponentBlueprintFilter(Filter):

def __init__(
self,
name: Union[str, None] = None,
component_type: Union[str, None] = None,
component_family: Union[str, None] = None,
tags: Union[List[str], None] = None,
name: "Optional[str]" = None,
component_type: "Optional[str]" = None,
component_family: "Optional[str]" = None,
tags: "Optional[List[str]]" = None,
):
kwargs = {
"name": name,
Expand Down
2 changes: 1 addition & 1 deletion indico/queries/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(
)

def process_response(
self, response: "Payload", _: "Optional[List[str]]" = None
self, response: "Payload", _: "Optional[str]" = None
) -> "List[Dataset]":
response = super().parse_payload(response)
return [Dataset(**dataset) for dataset in response["datasetsPage"]["datasets"]]
Expand Down
2 changes: 1 addition & 1 deletion indico/queries/document_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
super().__init__(self.query, variables=variables)

def process_response(
self, response: "Payload", _: "Optional[List[str]]" = None
self, response: "Payload", _: "Optional[str]" = None
) -> "List[DocumentReport]":
return _DocumentReportList(
**super().parse_payload(response)["submissionsLog"]
Expand Down
2 changes: 1 addition & 1 deletion indico/queries/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
)

def process_response(
self, response: "Payload", _: "Optional[List[str]]" = None
self, response: "Payload", _: "Optional[str]" = None
) -> "List[Example]":
example_page = super().parse_payload(response)["modelGroups"]["modelGroups"][0]
return [Example(**s) for s in example_page["pagedExamples"]["examples"]]
9 changes: 5 additions & 4 deletions indico/queries/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from indico.types.component_blueprint import BlueprintPage, BlueprintTags

if TYPE_CHECKING: # pragma: no cover
from typing import Any, List
from typing import Any

from indico.filters import ComponentBlueprintFilter
from indico.typing import AnyDict, Payload
from indico.typing import Payload


class ListGallery(PagedRequest[BlueprintPage]):
Expand Down Expand Up @@ -77,10 +77,11 @@ def __init__(
)

def process_response(
self, response: "Payload", _: "Optional[List[str]]" = None
self, response: "Payload", _: "Optional[str]" = None
) -> "BlueprintPage":
response = super().process_response(
response, nested_keys=["gallery", "component", "blueprintsPage"]
response,
jq_path=".gallery.component.blueprintsPage",
)
return BlueprintPage(
blueprints=[
Expand Down
2 changes: 1 addition & 1 deletion indico/queries/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(
)

def process_response(
self, response: "Payload", _: "Optional[List[str]]" = None
self, response: "Payload", _: "Optional[str]" = None
) -> "List[Submission]":
return [
Submission(**s)
Expand Down
4 changes: 2 additions & 2 deletions indico/queries/usermetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(
super().__init__(self.query, variables=variables)

def process_response(
self, response: "Payload", _: "Optional[List[str]]" = None
self, response: "Payload", _: "Optional[str]" = None
) -> "List[UserSnapshot]":
return _PagedUserSnapshots(
**super().parse_payload(response)["userSnapshot"]
Expand Down Expand Up @@ -181,7 +181,7 @@ def __init__(
super().__init__(self.query, variables=variables)

def process_response(
self, response: "Payload", _: "Optional[List[str]]" = None
self, response: "Payload", _: "Optional[str]" = None
) -> "List[UserChangelog]":
return _PagedUserChangelog(
**super().parse_payload(response)["userChangelog"]
Expand Down
Loading