Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sync client for v2 #137

Merged
merged 13 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy-unasync]
ignore_missing_imports = True
2 changes: 1 addition & 1 deletion docs/source/reference_async_v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The library also provides an asynchronous API for the client:

The ``AsyncFirecrest`` class
****************************
.. autoclass:: firecrest.v2.AsyncClient.AsyncFirecrest
.. autoclass:: firecrest.v2.AsyncFirecrest
:members:
:undoc-members:
:show-inheritance:
11 changes: 11 additions & 0 deletions docs/source/reference_sync_v2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FirecREST objects
==============================

Here is the API for the client:

The ``Firecrest`` class
****************************
.. autoclass:: firecrest.v2.Firecrest
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/source/reference_v2_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ API v2
:maxdepth: 2
:caption: Contents:

reference_sync_v2
reference_async_v2
3 changes: 3 additions & 0 deletions firecrest/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause
#

from firecrest.v2._async.Client import AsyncFirecrest
from firecrest.v2._sync.Client import Firecrest
20 changes: 3 additions & 17 deletions firecrest/v2/AsyncClient.py → firecrest/v2/_async/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
import pathlib
import ssl

import requests

from contextlib import asynccontextmanager
from io import BytesIO
from packaging.version import Version, parse
from typing import Any, ContextManager, Optional, List
from typing import Any, Optional, List

from firecrest.utilities import (
parse_retry_after, slurm_state_completed, time_block
slurm_state_completed, time_block
)
from firecrest.FirecrestException import (
FirecrestException,
Expand Down Expand Up @@ -55,18 +53,6 @@ def sleep_generator():
value *= 2 # Double the value for each iteration


@asynccontextmanager
async def async_file_context(file):
if isinstance(file, (str, pathlib.Path)):
# Open the file asynchronously if it's a string or path
async with aiofiles.open(file, "rb") as f:
print('opened file')
yield f
else:
# Use the file as-is if it's already a BytesIO or similar
yield file


class AsyncFirecrest:
"""
This is the basic class you instantiate to access the FirecREST API v2.
Expand Down Expand Up @@ -867,7 +853,7 @@ async def attach_to_job(

:param system_name: the system name where the filesystem belongs to
:param jobid: the ID of the job
command: the command to be executed
:param command: the command to be executed
:calls: PUT `/compute/{system_name}/jobs/{jobid}/attach`
"""
resp = await self._put_request(
Expand Down
Empty file added firecrest/v2/_async/__init__.py
Empty file.
Loading
Loading