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

guard dask import #417

Merged
merged 1 commit into from
Mar 7, 2024
Merged
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
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
Loading