Skip to content

Commit

Permalink
guard dask import (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanSoley committed Mar 7, 2024
1 parent 0cd94ee commit 8badb1a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rubicon_ml/client/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import warnings
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union

import dask.dataframe as dd
import pandas as pd

from rubicon_ml import domain
Expand All @@ -15,6 +14,8 @@
from rubicon_ml.schema.logger import SchemaMixin

if TYPE_CHECKING:
import dask.dataframe as dd

from rubicon_ml import Rubicon
from rubicon_ml.client import Config, Dataframe
from rubicon_ml.domain import Project as ProjectDomain
Expand Down Expand Up @@ -204,6 +205,15 @@ def to_df(
df = df.sort_values(by=["created_at"], ascending=False).reset_index(drop=True)

if df_type == "dask":
try:
from dask import dataframe as dd
except ImportError:
raise RubiconException(
"`rubicon_ml` requires `dask` to be installed in the current "
"environment to create dataframes with `df_type`='dask'. `pip install "
"dask[dataframe]` or `conda install dask` to continue."
)

df = dd.from_pandas(df, npartitions=1)

experiment_dfs[group] = df
Expand Down

0 comments on commit 8badb1a

Please sign in to comment.