Skip to content

Commit de64098

Browse files
Sung96kimjacobmandersonSung Kim
authored
[DEV-13108]: Ootb/Gallery (#357)
Co-authored-by: Jacob <jacob.anderson0004@gmail.com> Co-authored-by: Sung Kim <sung.kim@indico.io>
1 parent eafc403 commit de64098

39 files changed

Lines changed: 600 additions & 204 deletions

.harness/prinputset.yaml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
inputSet:
22
name: pr-input-set
3+
tags: {}
34
identifier: prinputset
45
orgIdentifier: default
56
projectIdentifier: IPA_Release
@@ -9,19 +10,10 @@ inputSet:
910
ci:
1011
codebase:
1112
build:
12-
type: PR
13+
type: branch
1314
spec:
14-
number: <+trigger.prNumber>
15+
branch: <+trigger.branch>
1516
stages:
16-
- stage:
17-
identifier: build_info
18-
type: CI
19-
spec:
20-
infrastructure:
21-
type: KubernetesDirect
22-
spec:
23-
nodeSelector:
24-
node_group: <+input>
2517
- parallel:
2618
- stage:
2719
identifier: code_checks
@@ -40,7 +32,7 @@ inputSet:
4032
value: <+input>
4133
- name: ruff
4234
type: String
43-
value: <+input>
35+
value: ruff format --check indico tests
4436
- name: mypy
4537
type: String
4638
value: <+input>
@@ -84,6 +76,12 @@ inputSet:
8476
- name: RUN_UNITTESTS
8577
type: String
8678
value: "TRUE"
79+
- name: RUN_PRERELEASE
80+
type: String
81+
value: "FALSE"
82+
- name: RUN_RELEASE
83+
type: String
84+
value: "FALSE"
8785
- name: RUN_PUBLISH
8886
type: String
8987
value: "FALSE"

indico/client/request.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from enum import Enum
2-
from typing import Any, Dict, Union
2+
from typing import Any, Dict, List, Optional, Union
33

4-
from indico.errors import IndicoRequestError
4+
from indico.errors import IndicoInputError, IndicoRequestError
55

66

77
class HTTPMethod(Enum):
@@ -73,9 +73,20 @@ def __init__(self, query: str, variables: Dict[str, Any] = None):
7373
self.has_next_page = True
7474
super().__init__(query, variables=variables)
7575

76-
def process_response(self, response):
76+
def process_response(self, response, nested_keys: Optional[List[str]] = None):
7777
response = super().process_response(response)
78-
_pg = next(iter(response.values()))["pageInfo"]
78+
if nested_keys:
79+
_pg = response
80+
for key in nested_keys:
81+
if key not in _pg.keys():
82+
raise IndicoInputError(
83+
f"Nested key not found in response: {key}",
84+
)
85+
_pg = _pg[key]
86+
_pg = _pg["pageInfo"]
87+
else:
88+
_pg = next(iter(response.values()))["pageInfo"]
89+
7990
self.has_next_page = _pg["hasNextPage"]
8091
self.variables["after"] = _pg["endCursor"] if self.has_next_page else None
8192
return response

indico/config/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class IndicoConfig:
3434
_disable_cookie_domain: bool = False
3535

3636
def __init__(self, **kwargs):
37-
3837
self.host: str = os.getenv("INDICO_HOST")
3938
self.protocol: str = os.getenv("INDICO_PROTOCOL", "https")
4039
self.serializer: str = os.getenv("INDICO_SERIALIZER", "msgpack")

indico/errors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ def __init__(self):
4343
class IndicoHibernationError(IndicoError):
4444
def __init__(self, after):
4545
self.after = after
46-
super().__init__(f"Platform is currently hibernating. Wait {after} seconds and retry this request.")
47-
46+
super().__init__(
47+
f"Platform is currently hibernating. Wait {after} seconds and retry this request."
48+
)

indico/filters/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,37 @@ def __init__(
252252
),
253253
}
254254
super().__init__(**kwargs)
255+
256+
257+
class ComponentBlueprintFilter(Filter):
258+
"""
259+
Create a Filter when querying for ComponentBlueprints.
260+
261+
Args:
262+
name (str): name of the component blueprint
263+
component_type (str): type of the component blueprint
264+
component_family (str): family of the component blueprint
265+
tags (list): tags of the component blueprint
266+
"""
267+
268+
__options__ = (
269+
"name",
270+
"component_type",
271+
"component_family",
272+
"tags",
273+
)
274+
275+
def __init__(
276+
self,
277+
name: Union[str, None] = None,
278+
component_type: Union[str, None] = None,
279+
component_family: Union[str, None] = None,
280+
tags: Union[List[str], None] = None,
281+
):
282+
kwargs = {
283+
"name": name,
284+
"componentType": component_type,
285+
"componentFamily": component_family,
286+
"tags": tags,
287+
}
288+
super().__init__(**kwargs)

indico/http/retry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from functools import wraps
66

77

8-
98
def retry(
109
ExceptionTypes: t.Type[Exception], tries: int = 3, delay: int = 1, backoff: int = 2
1110
) -> t.Callable:
@@ -32,6 +31,7 @@ def retry_fn(*args: t.Any, **kwargs: t.Any) -> t.Any:
3231

3332
return retry_decorator
3433

34+
3535
def aioretry(
3636
ExceptionTypes: t.Type[Exception],
3737
tries: int = 3,

indico/http/serialization.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Handles deserialization / decoding of responses
33
"""
4+
45
import gzip
56
import io
67
import json
@@ -42,6 +43,7 @@ def deserialize(response, force_json=False, force_decompress=False):
4243
content_type, charset, content.decode("ascii", "ignore")
4344
)
4445

46+
4547
async def aio_deserialize(response, force_json=False, force_decompress=False):
4648
content_type, params = parse_header(response.headers.get("Content-Type"))
4749
content = await response.read()
@@ -63,11 +65,13 @@ async def aio_deserialize(response, force_json=False, force_decompress=False):
6365
content_type, charset, content.decode("ascii", "ignore")
6466
)
6567

68+
6669
def parse_header(header: str) -> tuple[str, dict[str, str]]:
6770
email = EmailMessage()
6871
email["Content-Type"] = header
6972
return email.get_content_type(), email["Content-Type"].params
7073

74+
7175
def raw_bytes(content, *args, **kwargs):
7276
return content
7377

indico/queries/document_report.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""""""
2+
23
from typing import List, Union
34

45
from indico import PagedRequest
@@ -53,9 +54,16 @@ class GetDocumentReport(PagedRequest):
5354
"""
5455

5556
def __init__(
56-
self, filters: Union[dict, DocumentReportFilter] = None, limit: int = None, all_submissions = False
57+
self,
58+
filters: Union[dict, DocumentReportFilter] = None,
59+
limit: int = None,
60+
all_submissions=False,
5761
):
58-
variables = {"filters": filters, "limit": limit, "allSubmissions": all_submissions}
62+
variables = {
63+
"filters": filters,
64+
"limit": limit,
65+
"allSubmissions": all_submissions,
66+
}
5967
super().__init__(self.query, variables=variables)
6068

6169
def process_response(self, response):

indico/queries/documents.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

1111
class _DocumentExtraction(GraphQLRequest):
12-
1312
query = """
1413
mutation($files: [FileInput], $jsonConfig: JSONString, $ocrEngine: OCREngine) {
1514
documentExtraction(files: $files, jsonConfig: $jsonConfig, ocrEngine: $ocrEngine) {
@@ -22,7 +21,12 @@ def __init__(self, files, json_config={"preset_config": "legacy"}, ocr_engine=No
2221
if json_config and type(json_config) == dict:
2322
json_config = json.dumps(json_config)
2423
super().__init__(
25-
query=self.query, variables={"files": files, "jsonConfig": json_config, "ocrEngine": ocr_engine}
24+
query=self.query,
25+
variables={
26+
"files": files,
27+
"jsonConfig": json_config,
28+
"ocrEngine": ocr_engine,
29+
},
2630
)
2731

2832
def process_response(self, response):
@@ -67,7 +71,11 @@ class DocumentExtraction(RequestChain):
6771
"""
6872

6973
def __init__(
70-
self, files: List[str], json_config: dict = None, upload_batch_size: int = None, ocr_engine: str = "OMNIPAGE"
74+
self,
75+
files: List[str],
76+
json_config: dict = None,
77+
upload_batch_size: int = None,
78+
ocr_engine: str = "OMNIPAGE",
7179
):
7280
self.files = files
7381
self.json_config = json_config
@@ -83,4 +91,8 @@ def requests(self):
8391
)
8492
else:
8593
yield UploadDocument(files=self.files)
86-
yield _DocumentExtraction(files=self.previous, json_config=self.json_config, ocr_engine=self.ocr_engine)
94+
yield _DocumentExtraction(
95+
files=self.previous,
96+
json_config=self.json_config,
97+
ocr_engine=self.ocr_engine,
98+
)

indico/queries/forms.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
class _FormPreprocessing(GraphQLRequest):
10-
1110
query = """
1211
mutation($files: [FileInput]) {
1312
activeFormFields(

0 commit comments

Comments
 (0)