Skip to content

Commit 8184199

Browse files
[DEV-7697] ADD: Update SubmissionFile (#123)
* Add the newer file_size and num_pages to SubmissionFile * Update PR template
1 parent 4ce53b7 commit 8184199

File tree

3 files changed

+46
-53
lines changed

3 files changed

+46
-53
lines changed

.github/pull_request_template.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
## Summary
2-
2+
<!--
33
Please include a summary of the change and what the PR is trying to accomplish.
44
List any dependencies that are required for this change.
5+
-->
56

7+
<!--
68
## Changelog (optional)
79
List of changes, to easily get an idea of what was done.
810
911
Example:
1012
- Created new route `awesome_new_route_of_doom`
1113
- Create alembic migration for new table, `every_table_but_combined`
14+
-->
1215

1316
## Type of change
14-
17+
<!--
1518
Please delete options that are not relevant.
19+
-->
1620

1721
- [ ] Bug fix (non-breaking change which fixes an issue)
1822
- [ ] New feature (non-breaking change which adds functionality)
1923
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
2024
- [ ] This change requires a documentation update
2125

2226
## Checklist:
27+
<!--
2328
A quick checklist of things that should be done before the code is opened to review by others on the team.
2429
Delete any that are not applicable.
30+
-->
2531

2632
- [ ] Jira story/task is put into PR title
2733
- [ ] Code has been self-reviewed
@@ -30,4 +36,3 @@ Delete any that are not applicable.
3036
- [ ] My changes generate no new warnings
3137
- [ ] Unit tests have been added for base functionality and known edge cases
3238
- [ ] Any dependent changes have been merged and published in downstream modules
33-
- [ ] Any new GraphQL routes have descriptions for variables

indico/queries/submission.py

+30-45
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ListSubmissions(GraphQLRequest):
3636
$limit: Int,
3737
$orderBy: SUBMISSION_COLUMN_ENUM,
3838
$desc: Boolean
39-
39+
4040
){
4141
submissions(
4242
submissionIds: $submissionIds,
@@ -45,7 +45,7 @@ class ListSubmissions(GraphQLRequest):
4545
limit: $limit
4646
orderBy: $orderBy,
4747
desc: $desc
48-
48+
4949
){
5050
submissions {
5151
id
@@ -64,14 +64,14 @@ class ListSubmissions(GraphQLRequest):
6464
"""
6565

6666
def __init__(
67-
self,
68-
*,
69-
submission_ids: List[int] = None,
70-
workflow_ids: List[int] = None,
71-
filters: Union[Dict, SubmissionFilter] = None,
72-
limit: int = 1000,
73-
order_by: str = "ID",
74-
desc: bool = True,
67+
self,
68+
*,
69+
submission_ids: List[int] = None,
70+
workflow_ids: List[int] = None,
71+
filters: Union[Dict, SubmissionFilter] = None,
72+
limit: int = 1000,
73+
order_by: str = "ID",
74+
desc: bool = True,
7575
):
7676
super().__init__(
7777
self.query,
@@ -120,14 +120,8 @@ class GetSubmission(GraphQLRequest):
120120
}
121121
"""
122122

123-
def __init__(
124-
self,
125-
submission_id: int,
126-
):
127-
super().__init__(
128-
self.query,
129-
variables={"submissionId": submission_id},
130-
)
123+
def __init__(self, submission_id: int):
124+
super().__init__(self.query, variables={"submissionId": submission_id})
131125

132126
def process_response(self, response) -> Submission:
133127
return Submission(**(super().process_response(response)["submission"]))
@@ -161,11 +155,7 @@ class WaitForSubmissions(RequestChain):
161155
}
162156
"""
163157

164-
def __init__(
165-
self,
166-
submission_ids: List[int],
167-
timeout: Union[int, float] = 60,
168-
):
158+
def __init__(self, submission_ids: List[int], timeout: Union[int, float] = 60):
169159
if not submission_ids:
170160
raise IndicoInputError("Please provide submission ids")
171161

@@ -180,8 +170,8 @@ def requests(self) -> List[Submission]:
180170
yield self.status_getter()
181171
curr_time = 0
182172
while (
183-
not all(self.status_check(s.status) for s in self.previous)
184-
and curr_time <= self.timeout
173+
not all(self.status_check(s.status) for s in self.previous)
174+
and curr_time <= self.timeout
185175
):
186176
yield self.status_getter()
187177
time.sleep(1)
@@ -251,10 +241,7 @@ class GenerateSubmissionResult(GraphQLRequest):
251241

252242
def __init__(self, submission: Union[int, Submission]):
253243
submission_id = submission if isinstance(submission, int) else submission.id
254-
super().__init__(
255-
self.query,
256-
variables={"submissionId": submission_id},
257-
)
244+
super().__init__(self.query, variables={"submissionId": submission_id})
258245

259246
def process_response(self, response) -> Job:
260247
response = super().process_response(response)["submissionResults"]
@@ -288,11 +275,11 @@ class SubmissionResult(RequestChain):
288275
previous: Submission = None
289276

290277
def __init__(
291-
self,
292-
submission: Union[int, Submission],
293-
check_status: str = None,
294-
wait: bool = False,
295-
timeout: Union[int, float] = 30,
278+
self,
279+
submission: Union[int, Submission],
280+
check_status: str = None,
281+
wait: bool = False,
282+
timeout: Union[int, float] = 30,
296283
):
297284
self.submission_id = (
298285
submission if isinstance(submission, int) else submission.id
@@ -315,8 +302,8 @@ def requests(self) -> Union[Job, str]:
315302
if self.wait:
316303
curr_time = 0
317304
while (
318-
not self.status_check(self.previous.status)
319-
and curr_time <= self.timeout
305+
not self.status_check(self.previous.status)
306+
and curr_time <= self.timeout
320307
):
321308
yield GetSubmission(self.submission_id)
322309
time.sleep(1)
@@ -369,11 +356,11 @@ class SubmitReview(GraphQLRequest):
369356
}
370357

371358
def __init__(
372-
self,
373-
submission: Union[int, Submission],
374-
changes: Dict = None,
375-
rejected: bool = False,
376-
force_complete: bool = None,
359+
self,
360+
submission: Union[int, Submission],
361+
changes: Dict = None,
362+
rejected: bool = False,
363+
force_complete: bool = None,
377364
):
378365
submission_id = submission if isinstance(submission, int) else submission.id
379366
if not changes and not rejected:
@@ -412,6 +399,7 @@ class RetrySubmission(GraphQLRequest):
412399
Attributes:
413400
submission_ids (List[int]): the given submission ids to retry.
414401
"""
402+
415403
query = """
416404
mutation retrySubmission($submissionIds:[Int]!){
417405
retrySubmissions(submissionIds: $submissionIds){
@@ -433,10 +421,7 @@ def __init__(self, submission_ids: List[int]):
433421
if submission_ids is None or len(submission_ids) < 1:
434422
raise IndicoInputError("You must specify submission ids")
435423

436-
super().__init__(
437-
self.query,
438-
variables={"submissionIds": submission_ids},
439-
)
424+
super().__init__(self.query, variables={"submissionIds": submission_ids})
440425

441426
def process_response(self, response) -> List[Submission]:
442427
return [

indico/types/submission_file.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33

44
class SubmissionFile(BaseType):
5-
f"""
5+
"""
66
A Submission File in the Indico Platform.
77
88
Submissions files represent a single document, and can be grouped together under
99
a single submission to a submission to a workflow.
1010
1111
Attributes:
12-
id (int): the Submission file id
12+
id (int): The Submission file id
1313
filepath (str): URL of the input datafile within the Indico Platform.
14-
filename (str): name of the original file
15-
submission_id (int): the parent Submission id
16-
14+
filename (str): Name of the original file
15+
submission_id (int): The parent Submission id
16+
file_size (int): Size of file, in bytes
17+
num_pages (int): Number of pages in file
1718
"""
1819

1920
id: int
2021
filepath: str
2122
filename: str
2223
submission_id: int
24+
file_size: int
25+
num_pages: int

0 commit comments

Comments
 (0)