11"""Utils file for the run_benchmark module."""
22
3+ import os
34from datetime import datetime
45
5- from sdgym . benchmark import SDV_SINGLE_TABLE_SYNTHESIZERS
6+ from slack_sdk import WebClient
67
78OUTPUT_DESTINATION_AWS = 's3://sdgym-benchmark/Debug/Issue_425/'
89UPLOAD_DESTINATION_AWS = 's3://sdgym-benchmark/Debug/Issue_425/'
910DEBUG_SLACK_CHANNEL = 'sdv-alerts-debug'
1011SLACK_CHANNEL = 'sdv-alerts'
1112KEY_DATE_FILE = '_BENCHMARK_DATES.json'
12- SYNTHESIZERS = SDV_SINGLE_TABLE_SYNTHESIZERS
13+
14+ # The synthesizers inside the same list will be run by the same ec2 instance
15+ SYNTHESIZERS_SPLIT = [
16+ ['UniformSynthesizer' , 'ColumnSynthesizer' , 'GaussianCopulaSynthesizer' ],
17+ ['TVAESynthesizer' ],
18+ ['CopulaGANSynthesizer' ],
19+ ['CTGANSynthesizer' ],
20+ ['RealTabFormerSynthesizer' ],
21+ ]
1322
1423
1524def get_result_folder_name (date_str ):
@@ -20,3 +29,41 @@ def get_result_folder_name(date_str):
2029 raise ValueError (f'Invalid date format: { date_str } . Expected YYYY-MM-DD.' )
2130
2231 return f'SDGym_results_{ date .month :02d} _{ date .day :02d} _{ date .year } '
32+
33+
34+ def _get_slack_client ():
35+ """Create an authenticated Slack client.
36+
37+ Returns:
38+ WebClient:
39+ An authenticated Slack WebClient instance.
40+ """
41+ token = os .getenv ('SLACK_TOKEN' )
42+ client = WebClient (token = token )
43+ return client
44+
45+
46+ def post_slack_message (channel , text ):
47+ """Post a message to a Slack channel."""
48+ client = _get_slack_client ()
49+ client .chat_postMessage (channel = channel , text = text )
50+
51+
52+ def post_benchmark_launch_message ():
53+ """Post a message to the SDV Alerts Slack channel when the benchmark is launched."""
54+ channel = DEBUG_SLACK_CHANNEL
55+ body = 'SDGym benchmark has been launched! Results will be available soon.'
56+ post_slack_message (channel , body )
57+
58+
59+ def post_run_summary (folder_name ):
60+ """Post run summary to sdv-alerts slack channel."""
61+ channel = DEBUG_SLACK_CHANNEL
62+ body = ''
63+ body += f'SDGym benchmark results for { folder_name } are available!\n '
64+ body += (
65+ f'Check the results <{ OUTPUT_DESTINATION_AWS } { folder_name } /{ folder_name } _summary'
66+ '.csv|here>.\n '
67+ )
68+
69+ post_slack_message (channel , body )
0 commit comments