Skip to content

Commit

Permalink
[DEV-7697] ADD: Update SubmissionFile (#123)
Browse files Browse the repository at this point in the history
* Add the newer file_size and num_pages to SubmissionFile

* Update PR template
  • Loading branch information
adrianlacour-indico authored Oct 18, 2021
1 parent 4ce53b7 commit 8184199
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 53 deletions.
11 changes: 8 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
## Summary

<!--
Please include a summary of the change and what the PR is trying to accomplish.
List any dependencies that are required for this change.
-->

<!--
## Changelog (optional)
List of changes, to easily get an idea of what was done.
Example:
- Created new route `awesome_new_route_of_doom`
- Create alembic migration for new table, `every_table_but_combined`
-->

## Type of change

<!--
Please delete options that are not relevant.
-->

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

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

- [ ] Jira story/task is put into PR title
- [ ] Code has been self-reviewed
Expand All @@ -30,4 +36,3 @@ Delete any that are not applicable.
- [ ] My changes generate no new warnings
- [ ] Unit tests have been added for base functionality and known edge cases
- [ ] Any dependent changes have been merged and published in downstream modules
- [ ] Any new GraphQL routes have descriptions for variables
75 changes: 30 additions & 45 deletions indico/queries/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ListSubmissions(GraphQLRequest):
$limit: Int,
$orderBy: SUBMISSION_COLUMN_ENUM,
$desc: Boolean
){
submissions(
submissionIds: $submissionIds,
Expand All @@ -45,7 +45,7 @@ class ListSubmissions(GraphQLRequest):
limit: $limit
orderBy: $orderBy,
desc: $desc
){
submissions {
id
Expand All @@ -64,14 +64,14 @@ class ListSubmissions(GraphQLRequest):
"""

def __init__(
self,
*,
submission_ids: List[int] = None,
workflow_ids: List[int] = None,
filters: Union[Dict, SubmissionFilter] = None,
limit: int = 1000,
order_by: str = "ID",
desc: bool = True,
self,
*,
submission_ids: List[int] = None,
workflow_ids: List[int] = None,
filters: Union[Dict, SubmissionFilter] = None,
limit: int = 1000,
order_by: str = "ID",
desc: bool = True,
):
super().__init__(
self.query,
Expand Down Expand Up @@ -120,14 +120,8 @@ class GetSubmission(GraphQLRequest):
}
"""

def __init__(
self,
submission_id: int,
):
super().__init__(
self.query,
variables={"submissionId": submission_id},
)
def __init__(self, submission_id: int):
super().__init__(self.query, variables={"submissionId": submission_id})

def process_response(self, response) -> Submission:
return Submission(**(super().process_response(response)["submission"]))
Expand Down Expand Up @@ -161,11 +155,7 @@ class WaitForSubmissions(RequestChain):
}
"""

def __init__(
self,
submission_ids: List[int],
timeout: Union[int, float] = 60,
):
def __init__(self, submission_ids: List[int], timeout: Union[int, float] = 60):
if not submission_ids:
raise IndicoInputError("Please provide submission ids")

Expand All @@ -180,8 +170,8 @@ def requests(self) -> List[Submission]:
yield self.status_getter()
curr_time = 0
while (
not all(self.status_check(s.status) for s in self.previous)
and curr_time <= self.timeout
not all(self.status_check(s.status) for s in self.previous)
and curr_time <= self.timeout
):
yield self.status_getter()
time.sleep(1)
Expand Down Expand Up @@ -251,10 +241,7 @@ class GenerateSubmissionResult(GraphQLRequest):

def __init__(self, submission: Union[int, Submission]):
submission_id = submission if isinstance(submission, int) else submission.id
super().__init__(
self.query,
variables={"submissionId": submission_id},
)
super().__init__(self.query, variables={"submissionId": submission_id})

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

def __init__(
self,
submission: Union[int, Submission],
check_status: str = None,
wait: bool = False,
timeout: Union[int, float] = 30,
self,
submission: Union[int, Submission],
check_status: str = None,
wait: bool = False,
timeout: Union[int, float] = 30,
):
self.submission_id = (
submission if isinstance(submission, int) else submission.id
Expand All @@ -315,8 +302,8 @@ def requests(self) -> Union[Job, str]:
if self.wait:
curr_time = 0
while (
not self.status_check(self.previous.status)
and curr_time <= self.timeout
not self.status_check(self.previous.status)
and curr_time <= self.timeout
):
yield GetSubmission(self.submission_id)
time.sleep(1)
Expand Down Expand Up @@ -369,11 +356,11 @@ class SubmitReview(GraphQLRequest):
}

def __init__(
self,
submission: Union[int, Submission],
changes: Dict = None,
rejected: bool = False,
force_complete: bool = None,
self,
submission: Union[int, Submission],
changes: Dict = None,
rejected: bool = False,
force_complete: bool = None,
):
submission_id = submission if isinstance(submission, int) else submission.id
if not changes and not rejected:
Expand Down Expand Up @@ -412,6 +399,7 @@ class RetrySubmission(GraphQLRequest):
Attributes:
submission_ids (List[int]): the given submission ids to retry.
"""

query = """
mutation retrySubmission($submissionIds:[Int]!){
retrySubmissions(submissionIds: $submissionIds){
Expand All @@ -433,10 +421,7 @@ def __init__(self, submission_ids: List[int]):
if submission_ids is None or len(submission_ids) < 1:
raise IndicoInputError("You must specify submission ids")

super().__init__(
self.query,
variables={"submissionIds": submission_ids},
)
super().__init__(self.query, variables={"submissionIds": submission_ids})

def process_response(self, response) -> List[Submission]:
return [
Expand Down
13 changes: 8 additions & 5 deletions indico/types/submission_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@


class SubmissionFile(BaseType):
f"""
"""
A Submission File in the Indico Platform.
Submissions files represent a single document, and can be grouped together under
a single submission to a submission to a workflow.
Attributes:
id (int): the Submission file id
id (int): The Submission file id
filepath (str): URL of the input datafile within the Indico Platform.
filename (str): name of the original file
submission_id (int): the parent Submission id
filename (str): Name of the original file
submission_id (int): The parent Submission id
file_size (int): Size of file, in bytes
num_pages (int): Number of pages in file
"""

id: int
filepath: str
filename: str
submission_id: int
file_size: int
num_pages: int

0 comments on commit 8184199

Please sign in to comment.