File tree 7 files changed +48
-2
lines changed
7 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ This code implements [Convolutional Neural Networks for Sentence Classification]
13
13
- TensorFlow 1.4
14
14
- [ hb-config] ( https://github.com/hb-research/hb-config ) (Singleton Config)
15
15
- tqdm
16
+ - requests
17
+ - [ Slack Incoming Webhook URL] ( https://my.slack.com/services/new/incoming-webhook/ )
16
18
17
19
## Project Structure
18
20
80
82
loss_hook_n_iter : 1000
81
83
check_hook_n_iter : 1000
82
84
min_eval_frequency : 1000
85
+
86
+ slack :
87
+ webhook_url : " " # after training notify you using slack-webhook
83
88
` ` `
84
89
85
90
Original file line number Diff line number Diff line change 20
20
train :
21
21
learning_rate : 0.001
22
22
23
- train_steps : 10000
23
+ train_steps : 100
24
24
model_dir : ' logs/rt-check_tiny'
25
25
26
26
save_checkpoints_steps : 100
30
30
31
31
print_verbose : True
32
32
debug : False
33
+
34
+ slack :
35
+ webhook_url : " "
Original file line number Diff line number Diff line change 33
33
34
34
print_verbose : True
35
35
debug : False
36
+
37
+ slack :
38
+ webhook_url : " "
Original file line number Diff line number Diff line change 33
33
34
34
print_verbose : True
35
35
debug : False
36
+
37
+ slack :
38
+ webhook_url : " "
Original file line number Diff line number Diff line change 1
1
#-- coding: utf-8 -*-
2
2
3
3
import argparse
4
+ import atexit
4
5
import logging
5
6
6
7
from hbconfig import Config
9
10
import data_loader
10
11
import hook
11
12
from model import Model
13
+ import utils
12
14
13
15
14
16
def experiment_fn (run_config , params ):
@@ -92,7 +94,15 @@ def main(mode):
92
94
93
95
tf .logging ._logger .setLevel (logging .INFO )
94
96
97
+ # Print Config setting
95
98
Config (args .config )
96
99
print ("Config: " , Config )
100
+ if Config .get ("description" , None ):
101
+ print ("Config Description" )
102
+ for key , value in Config .description .items ():
103
+ print (f" - { key } : { value } " )
104
+
105
+ # After terminated Notification to Slack
106
+ atexit .register (utils .send_message_to_slack , config_name = args .config )
97
107
98
108
main (args .mode )
Original file line number Diff line number Diff line change 1
1
hb-config
2
- tqdm
2
+ tqdm
3
+ requests
Original file line number Diff line number Diff line change
1
+
2
+ import json
3
+ import os .path
4
+
5
+ from hbconfig import Config
6
+ import requests
7
+
8
+
9
+
10
+ def send_message_to_slack (config_name ):
11
+ project_name = os .path .basename (os .path .abspath ("." ))
12
+
13
+ data = {
14
+ "text" : f"The learning is finished with *{ project_name } * Project using `{ config_name } ` config."
15
+ }
16
+
17
+ webhook_url = Config .slack .webhook_url
18
+ if webhook_url == "" :
19
+ print (data ["text" ])
20
+ else :
21
+ requests .post (Config .slack .webhook_url , data = json .dumps (data ))
You can’t perform that action at this time.
0 commit comments