From 8184199ac2047166afcf246f94f2126dbd5c72ff Mon Sep 17 00:00:00 2001 From: Adrian LaCour <81830217+adrianlacour-indico@users.noreply.github.com> Date: Mon, 18 Oct 2021 13:28:26 -0500 Subject: [PATCH] [DEV-7697] ADD: Update SubmissionFile (#123) * Add the newer file_size and num_pages to SubmissionFile * Update PR template --- .github/pull_request_template.md | 11 +++-- indico/queries/submission.py | 75 +++++++++++++------------------- indico/types/submission_file.py | 13 +++--- 3 files changed, 46 insertions(+), 53 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 21833350..26e853a7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,18 +1,22 @@ ## Summary - + + ## Type of change - + - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) @@ -20,8 +24,10 @@ Please delete options that are not relevant. - [ ] This change requires a documentation update ## Checklist: + - [ ] Jira story/task is put into PR title - [ ] Code has been self-reviewed @@ -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 diff --git a/indico/queries/submission.py b/indico/queries/submission.py index 847138bc..52ff9d92 100644 --- a/indico/queries/submission.py +++ b/indico/queries/submission.py @@ -36,7 +36,7 @@ class ListSubmissions(GraphQLRequest): $limit: Int, $orderBy: SUBMISSION_COLUMN_ENUM, $desc: Boolean - + ){ submissions( submissionIds: $submissionIds, @@ -45,7 +45,7 @@ class ListSubmissions(GraphQLRequest): limit: $limit orderBy: $orderBy, desc: $desc - + ){ submissions { id @@ -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, @@ -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"])) @@ -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") @@ -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) @@ -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"] @@ -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 @@ -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) @@ -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: @@ -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){ @@ -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 [ diff --git a/indico/types/submission_file.py b/indico/types/submission_file.py index d0876c38..748571ea 100644 --- a/indico/types/submission_file.py +++ b/indico/types/submission_file.py @@ -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