Skip to content

Commit

Permalink
👌 Make dask client fixture scoped to session
Browse files Browse the repository at this point in the history
One local dask cluster client to run them all! Also a minor tweak to the boolean 'draining' variable.
  • Loading branch information
weiji14 committed Dec 19, 2020
1 parent 85f74a7 commit 24acc1c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions deepicedrain/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,21 @@ class Context:
return Context()


@pytest.fixture
def client():
@pytest.fixture(scope="session", name="client")
def fixture_client():
"""
A dask distributed client to throw compute tasks at!
"""
import dask

tag: str = "X2SYS"
os.environ["X2SYS_HOME"] = os.path.abspath(tag)
_client = dask.distributed.Client(
client = dask.distributed.Client(
n_workers=8, threads_per_worker=1, env={"X2SYS_HOME": os.environ["X2SYS_HOME"]}
)
yield client

yield _client

_client.shutdown()
client.shutdown()


@given("some altimetry data over <lake_name> at <location>", target_fixture="df_lake")
Expand Down Expand Up @@ -74,7 +73,7 @@ def lake_altimetry_data(lake_name: str, location: str, context) -> pd.DataFrame:
context.region = deepicedrain.Region.from_gdf(
gdf=context.lake, name=context.lake_name
)
context.draining: bool = True if context.lake.inner_dhdt < 0 else False
context.draining: bool = context.lake.inner_dhdt < 0

# Subset data to lake of interest
context.placename: str = context.lake_name.lower().replace(" ", "_")
Expand Down

0 comments on commit 24acc1c

Please sign in to comment.