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 test for executor #286

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
pip install . --no-deps --no-build-isolation
- name: Test
shell: bash -l {0}
timeout-minutes: 2
run: >
flux start
coverage run --omit="pysqa/_version.py,tests/*" -m unittest discover tests
Expand Down
23 changes: 22 additions & 1 deletion tests/test_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Copyright (c) Jan Janssen

import os
from time import sleep
import unittest

import pandas
from pysqa import QueueAdapter
from pysqa.executor.executor import Executor


try:
Expand All @@ -16,11 +16,17 @@
skip_flux_test = True


def funct_add(a, b):
return a+b


@unittest.skipIf(skip_flux_test, "Flux is not installed, so the flux tests are skipped.")
class TestFluxQueueAdapter(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.path = os.path.dirname(os.path.abspath(__file__))
cls.test_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "cache")
os.makedirs(cls.test_dir, exist_ok=True)
cls.flux = QueueAdapter(directory=os.path.join(cls.path, "config/flux"))

def test_config(self):
Expand Down Expand Up @@ -106,3 +112,18 @@ def test_flux_integration(self):
self.assertEqual(self.flux.get_status_of_job(process_id=job_id), 'running')
self.flux.delete_job(process_id=job_id)
self.assertEqual(self.flux.get_status_of_job(process_id=job_id), 'error')

def test_executor_integration(self):
with Executor(
cwd=self.test_dir,
queue_adapter=self.flux,
queue_adapter_kwargs={
"queue": "flux",
"job_name": "test",
"cores": 1,
}
) as exe:
fs = exe.submit(fn=funct_add, a=1, b=2)
self.assertFalse(fs.done())
self.assertEqual(fs.result(), 3)
self.assertTrue(fs.done())
Loading