From 376fe1f6d736b127a6b2200a4d64a263e5187323 Mon Sep 17 00:00:00 2001 From: Chris Harris Date: Wed, 10 Apr 2024 12:25:05 +0000 Subject: [PATCH 1/2] Add model_rebuild for job models --- src/sfapi_client/_async/client.py | 6 ++++++ src/sfapi_client/_sync/client.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/sfapi_client/_async/client.py b/src/sfapi_client/_async/client.py index 1278f97..81e2d51 100644 --- a/src/sfapi_client/_async/client.py +++ b/src/sfapi_client/_async/client.py @@ -512,3 +512,9 @@ def resources(self) -> AsyncResources: AsyncRemotePath.model_rebuild() AsyncRole.model_rebuild() AsyncGroupMember.model_rebuild() + +# Ensure that the job models are built, we need to import here to +# avoid circular imports +from .jobs import AsyncJobSacct, AsyncJobSqueue +AsyncJobSqueue.model_rebuild() +AsyncJobSacct.model_rebuild() \ No newline at end of file diff --git a/src/sfapi_client/_sync/client.py b/src/sfapi_client/_sync/client.py index ee4b92c..cc6aae1 100644 --- a/src/sfapi_client/_sync/client.py +++ b/src/sfapi_client/_sync/client.py @@ -512,3 +512,9 @@ def resources(self) -> Resources: RemotePath.model_rebuild() Role.model_rebuild() GroupMember.model_rebuild() + +# Ensure that the job models are built, we need to import here to +# avoid circular imports +from .jobs import JobSacct, JobSqueue +JobSqueue.model_rebuild() +JobSacct.model_rebuild() \ No newline at end of file From cfb2ac3ace0fcd248375122804866b1a1e2c419d Mon Sep 17 00:00:00 2001 From: Chris Harris Date: Wed, 10 Apr 2024 12:28:08 +0000 Subject: [PATCH 2/2] Fix ruff issues --- src/sfapi_client/_async/client.py | 5 +++-- src/sfapi_client/_async/paths.py | 5 ++++- src/sfapi_client/_async/users.py | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sfapi_client/_async/client.py b/src/sfapi_client/_async/client.py index 81e2d51..c8debb9 100644 --- a/src/sfapi_client/_async/client.py +++ b/src/sfapi_client/_async/client.py @@ -515,6 +515,7 @@ def resources(self) -> AsyncResources: # Ensure that the job models are built, we need to import here to # avoid circular imports -from .jobs import AsyncJobSacct, AsyncJobSqueue +from .jobs import AsyncJobSacct, AsyncJobSqueue # noqa: E402 + AsyncJobSqueue.model_rebuild() -AsyncJobSacct.model_rebuild() \ No newline at end of file +AsyncJobSacct.model_rebuild() diff --git a/src/sfapi_client/_async/paths.py b/src/sfapi_client/_async/paths.py index febb8c4..c08f480 100644 --- a/src/sfapi_client/_async/paths.py +++ b/src/sfapi_client/_async/paths.py @@ -165,7 +165,10 @@ async def download(self, binary=False) -> IO[AnyStr]: @staticmethod async def _ls( - compute: "Compute", path, directory=False, filter_dots=True # noqa: F821 + compute: "AsyncCompute", # noqa: F821 + path, + directory=False, + filter_dots=True, # noqa: F821 ) -> List["RemotePath"]: # noqa: F821 r = await compute.client.get(f"utilities/ls/{compute.name}/{path}") diff --git a/src/sfapi_client/_async/users.py b/src/sfapi_client/_async/users.py index adb6241..73fe379 100644 --- a/src/sfapi_client/_async/users.py +++ b/src/sfapi_client/_async/users.py @@ -31,7 +31,8 @@ class AsyncUser(UserBase): @staticmethod @check_auth async def _fetch_user( - client: "AsyncClient", username: Optional[str] = None # noqa: F821 + client: "AsyncClient", # noqa: F821 + username: Optional[str] = None, # noqa: F821 ): # noqa: F821 url = "account/" if username is not None: