Skip to content

Commit

Permalink
Muting warnings for silent mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneTR committed Oct 10, 2023
1 parent c68e4d1 commit eda962e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions xgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def interpolate_predictions(predictions):
action='store_true',
help='Will suppress all debug output. Typically used in production.'
)

parser.add_argument('--energy',
action='store_true',
help='Switches to energy mode. The output will be in Joules instead of Watts. \
Expand All @@ -122,13 +123,19 @@ def interpolate_predictions(predictions):

Z = Z.dropna(axis=1)

trained_model = train_model(args.cpu_chips, Z, args.silent)

if not args.silent:
if args.silent:
# sadly some libs have future warnings we need to suppress for
# silent mode to work in bash scripts
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
else:
print('Sending following dataframe to model:\n', Z)
print('vHost ratio is set to ', args.vhost_ratio)
print('Infering all predictions to dictionary')

trained_model = train_model(args.cpu_chips, Z, args.silent)


inferred_predictions = infer_predictions(trained_model, Z)
interpolated_predictions = interpolate_predictions(inferred_predictions)

Expand All @@ -139,7 +146,6 @@ def interpolate_predictions(predictions):
(time.time_ns() - current_time) / 1_000_000_000
)
current_time = time.time_ns()

else:
for line in sys.stdin:
print(interpolated_predictions[float(line.strip())] * args.vhost_ratio)

0 comments on commit eda962e

Please sign in to comment.