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

Fix issue with jobs db requests #94

Merged
merged 2 commits into from
Dec 16, 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
4 changes: 3 additions & 1 deletion src/sfapi_client/_async/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async def _fetch_raw_state(
partition: Optional[str] = None,
sacct: Optional[bool] = False,
):
params = {"sacct": sacct}
# For now we are pass cached=False to ensure we don't
# break compatibility
params = {"sacct": sacct, "cached": False}

job_url = f"compute/jobs/{compute.name}"

Expand Down
5 changes: 1 addition & 4 deletions src/sfapi_client/_sync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,7 @@ def get(self, url: str, params: Dict[str, Any] = {}) -> httpx.Response:
stop=tenacity.stop_after_attempt(MAX_RETRY),
)
def post(
self,
url: str,
data: Dict[str, Any] = None,
json: Dict[str, Any] = None
self, url: str, data: Dict[str, Any] = None, json: Dict[str, Any] = None
) -> httpx.Response:
client = self._http_client()

Expand Down
4 changes: 3 additions & 1 deletion src/sfapi_client/_sync/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def _fetch_raw_state(
partition: Optional[str] = None,
sacct: Optional[bool] = False,
):
params = {"sacct": sacct}
# For now we are pass cached=False to ensure we don't
# break compatibility
params = {"sacct": sacct, "cached": False}

job_url = f"compute/jobs/{compute.name}"

Expand Down
28 changes: 4 additions & 24 deletions tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from concurrent.futures import ThreadPoolExecutor
import time

from sfapi_client import Client
from sfapi_client.jobs import JobState
from sfapi_client.compute import Compute
from sfapi_client.jobs import JobSqueue
Expand Down Expand Up @@ -52,22 +51,13 @@ def test_complete_timeout(authenticated_client, test_job_path, test_machine):
job.complete(timeout=10)


@pytest.mark.api_dev
def test_job_monitor_check_request(
mocker,
dev_client_id,
dev_client_secret,
authenticated_client,
test_job_path,
test_machine,
dev_api_url,
dev_token_url,
):
with Client(
client_id=dev_client_id,
secret=dev_client_secret,
api_base_url=dev_api_url,
token_url=dev_token_url,
) as client:
with authenticated_client as client:
num_jobs = 10
_fetch_jobs = mocker.patch("sfapi_client._monitor._fetch_jobs")

Expand Down Expand Up @@ -122,24 +112,14 @@ def _jobs(*arg, **kwargs):
assert len(ids) == num_jobs


# We currently run this in api-dev as its a new feature deployed there
@pytest.mark.api_dev
def test_job_monitor_multiple_threads(
dev_client_id,
dev_client_secret,
authenticated_client,
test_job_path,
test_machine,
dev_api_url,
dev_token_url,
):
num_jobs = 5

with Client(
client_id=dev_client_id,
secret=dev_client_secret,
api_base_url=dev_api_url,
token_url=dev_token_url,
) as client:
with authenticated_client as client:
machine = client.compute(test_machine)

jobs = []
Expand Down
17 changes: 2 additions & 15 deletions tests/test_jobs_async.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
import asyncio

from sfapi_client import AsyncClient
from sfapi_client.compute import AsyncCompute
from sfapi_client.jobs import AsyncJobSqueue, AsyncJobSacct, JobState

Expand Down Expand Up @@ -162,23 +161,11 @@ async def test_job_monitor_job_types(async_authenticated_client, mocker, test_ma
assert kwargs["job_type"] == AsyncJobSacct


# We currently run this in api-dev as its a new feature deployed there
@pytest.mark.api_dev
@pytest.mark.asyncio
async def test_job_monitor_gather(
dev_client_id,
dev_client_secret,
test_job_path,
test_machine,
dev_api_url,
dev_token_url,
async_authenticated_client, test_job_path, test_machine
):
async with AsyncClient(
client_id=dev_client_id,
secret=dev_client_secret,
api_base_url=dev_api_url,
token_url=dev_token_url,
) as client:
async with async_authenticated_client as client:
machine = await client.compute(test_machine)

submit_tasks = []
Expand Down
Loading