Skip to content

Commit

Permalink
import fixed: find the last occurence of views_pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Borbála Farkas authored and Borbála Farkas committed Oct 29, 2024
1 parent b3897d4 commit 8b37ce7
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check_if_new_model_added.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
else
echo "No new or removed folders detected."
fi
git status
- name: Configure Git
run: |
Expand Down
3 changes: 2 additions & 1 deletion documentation/catalogs/generate_model_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from pathlib import Path

PATH = Path(__file__).resolve()
PATH_ROOT = PATH.parent.parent.parent
indices = [i for i, x in enumerate(PATH.parts) if x == "views_pipeline"]
PATH_ROOT = Path(*PATH.parts[:indices[-1] + 1])

sys.path.insert(0, str(PATH_ROOT))
sys.path.insert(0, str(PATH_ROOT/"common_utils"))
Expand Down
3 changes: 3 additions & 0 deletions models/caring_fish/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Model README
## Model name: caring_fish
## Created on: 2024-10-29 10:51:00.014047
20 changes: 20 additions & 0 deletions models/caring_fish/configs/config_deployment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Deployment Configuration Script
This script defines the deployment configuration settings for the application.
It includes the deployment status and any additional settings specified.
Deployment Status:
- shadow: The deployment is shadowed and not yet active.
- deployed: The deployment is active and in use.
- baseline: The deployment is in a baseline state, for reference or comparison.
- deprecated: The deployment is deprecated and no longer supported.
Additional settings can be included in the configuration dictionary as needed.
"""

def get_deployment_config():
# Deployment settings
deployment_config = {'deployment_status': 'shadow'}
return deployment_config
14 changes: 14 additions & 0 deletions models/caring_fish/configs/config_hyperparameters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def get_hp_config():
"""
Contains the hyperparameter configurations for model training.
This configuration is "operational" so modifying these settings will impact the model's behavior during the training.
Returns:
- hyperparameters (dict): A dictionary containing hyperparameters for training the model, which determine the model's behavior during the training phase.
"""

hyperparameters = {
'model': 'XGBoost', # The model algorithm used. Eg. "LSTM", "CNN", "Transformer"
# Add more hyperparameters as needed
}
return hyperparameters
19 changes: 19 additions & 0 deletions models/caring_fish/configs/config_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def get_meta_config():
"""
Contains the meta data for the model (model algorithm, name, target variable, and level of analysis).
This config is for documentation purposes only, and modifying it will not affect the model, the training, or the evaluation.
Returns:
- meta_config (dict): A dictionary containing model meta configuration.
"""

meta_config = {
"name": "caring_fish", # Eg. happy_kitten
"algorithm": "XGBoost", # Eg. "LSTM", "CNN", "Transformer"
# Uncomment and modify the following lines as needed for additional metadata:
# "target(S)": ["ln_sb_best", "ln_ns_best", "ln_os_best", "ln_sb_best_binarized", "ln_ns_best_binarized", "ln_os_best_binarized"],
"queryset": "escwa001_cflong"
# "level": "pgm",
# "creator": "Your name here"
}
return meta_config
29 changes: 29 additions & 0 deletions models/caring_fish/configs/config_sweep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def get_sweep_config():
"""
Contains the configuration for hyperparameter sweeps using WandB.
This configuration is "operational" so modifying it will change the search strategy, parameter ranges, and other settings for hyperparameter tuning aimed at optimizing model performance.
Returns:
- sweep_config (dict): A dictionary containing the configuration for hyperparameter sweeps, defining the methods and parameter ranges used to search for optimal hyperparameters.
"""

sweep_config = {
'method': 'grid',
}

# Example metric setup:
metric = {
'name': 'MSE',
'goal': 'minimize'
}
sweep_config['metric'] = metric

# Example parameters setup:
parameters_dict = {
'model': {
'value': 'XGBoost' # Eg. "LSTM", "CNN", "Transformer"
},
}
sweep_config['parameters'] = parameters_dict

return sweep_config
39 changes: 39 additions & 0 deletions models/caring_fish/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import time
import wandb
import sys
import logging
logging.basicConfig(filename='run.log', encoding='utf-8', level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
from pathlib import Path
# Set up the path to include common_utils module
PATH = Path(__file__)
sys.path.insert(0, str(Path(
*[i for i in PATH.parts[:PATH.parts.index("views_pipeline") + 1]]) / "common_utils")) # PATH_COMMON_UTILS
# Import necessary functions for project setup and model execution
from set_path import setup_project_paths
setup_project_paths(PATH)
from utils_cli_parser import parse_args, validate_arguments
from execute_model_runs import execute_sweep_run, execute_single_run

if __name__ == "__main__":
# Parse command-line arguments
args = parse_args()

# Validate the arguments to ensure they are correct
validate_arguments(args)
# Log in to Weights & Biases (wandb)
wandb.login()
# Record the start time
start_t = time.time()
# Execute the model run based on the sweep flag
if args.sweep:
execute_sweep_run(args) # Execute sweep run
else:
execute_single_run(args) # Execute single run
# Record the end time
end_t = time.time()

# Calculate and print the runtime in minutes
minutes = (end_t - start_t) / 60
logger.info(f'Done. Runtime: {minutes:.3f} minutes')
1 change: 1 addition & 0 deletions models/caring_fish/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Requirements

0 comments on commit 8b37ce7

Please sign in to comment.