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

[cleanup] cleanup loggers for console/notebook #1181

Merged
merged 4 commits into from
Dec 6, 2024
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
2 changes: 1 addition & 1 deletion python/src/robyn/allocator/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _run_optimization(self, bounded: bool = True) -> OptimizationResult:
options={
"ftol": 1e-10,
"maxiter": self.params.maxeval,
"disp": True,
"disp": False,
},
)

Expand Down
9 changes: 6 additions & 3 deletions python/src/robyn/data/entities/mmmdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
OrganicSigns,
PaidMediaSigns,
)
import logging

logger = logging.getLogger(__name__)


@dataclass
Expand Down Expand Up @@ -168,7 +171,7 @@ def display_data(self) -> None:
"""
Display the contents of the DataFrame.
"""
print(self.data)
logger.debug(self.data)

def get_summary(self) -> pd.DataFrame:
"""
Expand Down Expand Up @@ -223,7 +226,7 @@ def calculate_rolling_window_indices(self) -> None:
self.mmmdata_spec.rolling_window_start_which = closest_start_idx
# Adjust window_start to the closest date in the data
self.mmmdata_spec.window_start = closest_start_date
print(
logger.debug(
f"Adjusted window_start to the closest date in the data: {closest_start_date}"
)

Expand All @@ -238,7 +241,7 @@ def calculate_rolling_window_indices(self) -> None:
self.mmmdata_spec.rolling_window_end_which = closest_end_idx
# Adjust window_end to the closest date in the data
self.mmmdata_spec.window_end = closest_end_date
print(
logger.debug(
f"Adjusted window_end to the closest date in the data: {closest_end_date}"
)

Expand Down
5 changes: 4 additions & 1 deletion python/src/robyn/modeling/feature_engineering.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
from robyn.data.entities.mmmdata import MMMData


logger = logging.getLogger(__name__)


class FeatureEngineering:
"""
A class used to perform feature engineering for Marketing Mix Modeling (MMM) data.
Expand All @@ -34,7 +37,7 @@ def __init__(
self.mmm_data = mmm_data
self.hyperparameters = hyperparameters
self.holidays_data = holidays_data
self.logger = logging.getLogger(__name__)
self.logger = logger
self.logger.debug(
"Initializing FeatureEngineering with MMM data and hyperparameters"
)
Expand Down
8 changes: 5 additions & 3 deletions python/src/robyn/robyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from logging.handlers import RotatingFileHandler
from pathlib import Path
from typing import Dict, Optional, List
from typing import Dict, Optional
import copy
from robyn.data.entities.mmmdata import MMMData
from robyn.data.entities.holidays_data import HolidaysData
Expand All @@ -15,7 +15,6 @@
from robyn.modeling.entities.modeloutputs import ModelOutputs
from robyn.modeling.entities.modelrun_trials_config import TrialsConfig
from robyn.modeling.entities.enums import Models, NevergradAlgorithm
from robyn.modeling.entities.pareto_result import ParetoResult
from robyn.modeling.model_executor import ModelExecutor

from robyn.modeling.pareto.pareto_optimizer import ParetoOptimizer
Expand All @@ -34,6 +33,7 @@
from robyn.visualization.feature_visualization import FeaturePlotter
from robyn.visualization.model_convergence_visualizer import ModelConvergenceVisualizer
from robyn.visualization.pareto_visualizer import ParetoVisualizer
import matplotlib.pyplot as plt

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -288,6 +288,7 @@ def evaluate_models(
self.mmm_data,
)
cluster_visualizer.plot_all(display_plots, self.working_dir)
plt.close("all")
logger.info("Model evaluation complete")

except Exception as e:
Expand Down Expand Up @@ -425,7 +426,8 @@ def generate_one_pager(self, solution_id: Optional[str] = None) -> None:
solution_ids=solution_id if solution_id else "all",
top_pareto=top_pareto,
)
return figures
# return None instead of figures
return None

except Exception as e:
logging.error("One-pager generation failed: %s", str(e))
Expand Down
Loading
Loading