Skip to content
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: 2 additions & 2 deletions src/fmcore/framework/_evaluator/RayEvaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def _run_evaluation(
progress_bar,
total=num_actors_created,
desc=f"Submitting {input_len_str} rows",
unit="submissions",
unit="batch",
)
## Each actor streams data from Dask dataframe on the cluster:
if not isinstance(data, DaskScalableDataFrame):
Expand Down Expand Up @@ -693,7 +693,7 @@ def _run_evaluation(
progress_bar,
total=math.ceil(input_len / submission_batch_size),
desc=f"Submitting {input_len_str} rows",
unit="submissions",
unit="batch",
)
## Initialize to zero:
rows_completed: int = ray.get(row_counter.get_rows_completed.remote())
Expand Down
3 changes: 2 additions & 1 deletion src/fmcore/framework/_task/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from bears import ScalableDataFrame, ScalableSeries
from bears.processor import EncodingRange, LabelEncoding
from bears.util import all_are_np_subtypes, as_list, as_tuple, is_list_or_set_like, safe_validate_arguments
from bears.util.language._import import np_bool, np_floating, np_integer
from pydantic import constr

from fmcore.constants import DataLayout, DataSplit, MLType, MLTypeSchema, Task
Expand Down Expand Up @@ -268,7 +269,7 @@ def from_top_k(
labels: np.ndarray = np.array(labels)
if isinstance(scores, (list, tuple)):
scores: np.ndarray = np.array(scores)
if not all_are_np_subtypes(scores.dtype, {np.bool, np.integer, np.floating}):
if not all_are_np_subtypes(scores.dtype, {np_bool, np_integer, np_floating}):
raise ValueError(
f"Expected scores array to have dtype as bool, int or float; found: {scores.dtype}"
)
Expand Down
8 changes: 4 additions & 4 deletions src/fmcore/framework/_trainer/RayTuneTrainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
set_param_from_alias,
type_str,
)
from bears.util.language._import import _IS_RAY_INSTALLED, _IS_TORCH_INSTALLED
from pydantic import conint, model_validator, ConfigDict
from bears.util.language._import import _IS_RAY_INSTALLED, _IS_TORCH_INSTALLED, np_number
from pydantic import ConfigDict, conint, model_validator

from fmcore.constants import DataLayout
from fmcore.framework._algorithm import Algorithm
Expand Down Expand Up @@ -93,7 +93,7 @@ def _ray_put_metric_value(metric: Metric) -> Any:
assert isinstance(metric.value, pd.DataFrame)
return _RAY_METRIC_IS_DATAFRAME_PREFIX + metric.value.to_json(orient="records")
value: Any = metric.value
if isinstance(value, (int, float, str)) or np.issubdtype(type(value), np.number):
if isinstance(value, (int, float, str)) or np.issubdtype(type(value), np_number):
return value
buf = io.BytesIO()
pickle.dump(value, buf)
Expand All @@ -106,7 +106,7 @@ def _ray_get_metric_value(value: Optional[Any]) -> Optional[Any]:
return None
if isinstance(value, str) and value.startswith(_RAY_METRIC_IS_DATAFRAME_PREFIX):
return pd.DataFrame(json.loads(value.removeprefix(_RAY_METRIC_IS_DATAFRAME_PREFIX)))
if isinstance(value, (int, float, str)) or np.issubdtype(type(value), np.number):
if isinstance(value, (int, float, str)) or np.issubdtype(type(value), np_number):
return value
if not isinstance(value, io.BytesIO):
raise ValueError(f"Expected metric value to be of type BytesIO, found type: {type_str(value)}")
Expand Down