Skip to content

Commit e1c59d2

Browse files
committed
remove ray when low cpu count
1 parent 3dafe31 commit e1c59d2

File tree

1 file changed

+10
-2
lines changed
  • ads/opctl/operator/lowcode/forecast/model

1 file changed

+10
-2
lines changed

ads/opctl/operator/lowcode/forecast/model/automlx.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright (c) 2023, 2024 Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44
import logging
5+
import os
56
import traceback
67

78
import numpy as np
@@ -80,10 +81,17 @@ def _build_model(self) -> pd.DataFrame:
8081

8182
from automlx import Pipeline, init
8283

84+
cpu_count = os.cpu_count()
8385
try:
86+
if cpu_count < 4:
87+
engine = "local"
88+
engine_opts = None
89+
else:
90+
engine = "ray"
91+
engine_opts = ({"ray_setup": {"_temp_dir": "/tmp/ray-temp"}},)
8492
init(
85-
engine="ray",
86-
engine_opts={"ray_setup": {"_temp_dir": "/tmp/ray-temp"}},
93+
engine=engine,
94+
engine_opts=engine_opts,
8795
loglevel=logging.CRITICAL,
8896
)
8997
except Exception as e:

0 commit comments

Comments
 (0)