Skip to content

Commit

Permalink
Merge pull request #276 from datmo/dashboard-update
Browse files Browse the repository at this point in the history
Dashboard update with simplified graph additions and custom graphs
  • Loading branch information
asampat3090 committed Oct 31, 2018
2 parents 8c0c65b + f340d93 commit ac622ee
Show file tree
Hide file tree
Showing 10 changed files with 859 additions and 1,155 deletions.
9 changes: 4 additions & 5 deletions datmo/cli/command/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ def ls(self, **kwargs):
sys.exit(response.status)
current_cluster_information = response.result
header_list = [
'cluster name', 'server type', 'count', 'service path',
'service url'
'name', 'server type', 'count', 'service path', 'service url'
]
table_header_list = []
for i in header_list:
Expand All @@ -194,7 +193,7 @@ def ls(self, **kwargs):
cluster_server_count, '', ''
])
deploy_item = {
"cluster name": cluster_name,
"name": cluster_name,
"server type": cluster_server_type,
"count": cluster_server_count,
"service path": "",
Expand All @@ -211,7 +210,7 @@ def ls(self, **kwargs):
])
displayed_cluster_names.append(cluster_name)
deploy_item = {
"cluster name": cluster_name,
"name": cluster_name,
"server type": cluster_server_type,
"count": cluster_server_count,
"service path": service_route,
Expand All @@ -220,7 +219,7 @@ def ls(self, **kwargs):
else:
t.add_row(['', '', '', service_route, service_url])
deploy_item = {
"cluster name": "",
"name": "",
"server type": "",
"count": "",
"service path": service_route,
Expand Down
9 changes: 6 additions & 3 deletions datmo/core/controller/deploy/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@ def model_deploy(self, cluster_name):
'files_exclude']
for item in list_dir:
if item in files_exclude:
if os.path.isfile(os.path.join(tmp_dirpath, item)):
os.remove(os.path.join(tmp_dirpath, item))
elif os.path.isdir(os.path.join(tmp_dirpath, item)):
if os.path.isfile(
os.path.join(tmp_dirpath, item)):
os.remove(
os.path.join(tmp_dirpath, item))
elif os.path.isdir(
os.path.join(tmp_dirpath, item)):
shutil.rmtree(
os.path.join(tmp_dirpath, item))

Expand Down
55 changes: 31 additions & 24 deletions datmo/core/util/misc_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,37 @@ def slack_message(webhook_url, options):
return False

slack_data = {
"attachments": [
{
"fallback": "Trigger from Datmo",
"color": "warning",
"pretext": "Trigger from Datmo during inference",
"author_name": options.get("author_name"),
"title": options.get("title"),
"text": options.get("text"),
"fields": [
{
"title": "Priority",
"value": options.get("priority")
if options.get("priority") is not None else "High",
"short": False
}
],
"ts": options.get("timestamp")
}
]
}

response = requests.post(webhook_url,
data=json.dumps(slack_data),
headers={'Content-Type': 'application/json'})
"attachments": [{
"fallback":
"Trigger from Datmo",
"color":
"warning",
"pretext":
"Trigger from Datmo during inference",
"author_name":
options.get("author_name"),
"title":
options.get("title"),
"text":
options.get("text"),
"fields": [{
"title":
"Priority",
"value":
options.get("priority")
if options.get("priority") is not None else "High",
"short":
False
}],
"ts":
options.get("timestamp")
}]
}

response = requests.post(
webhook_url,
data=json.dumps(slack_data),
headers={'Content-Type': 'application/json'})
if response.status_code != 200:
return False

Expand Down
14 changes: 9 additions & 5 deletions datmo/core/util/tests/test_misc_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def to_bytes(val):
to_bytes("test")

from datmo.core.util.misc_functions import (
bytes2human, slack_message, create_unique_hash, mutually_exclusive, is_project_dir,
find_project_dir, grep, prettify_datetime, format_table,
bytes2human, slack_message, create_unique_hash, mutually_exclusive,
is_project_dir, find_project_dir, grep, prettify_datetime, format_table,
parse_cli_key_value, convert_keys_to_string, get_datmo_temp_path,
parse_path, parse_paths, list_all_filepaths)

Expand Down Expand Up @@ -119,8 +119,13 @@ def test_bytes2human(self):

def test_slack_message(self):
# Setting up the options for slack message
options = {"author_name": "testing misc functions", "title": "Test title", "text": "Test text",
"priority": "just chill!", "timestamp": int(round(time.time()))}
options = {
"author_name": "testing misc functions",
"title": "Test title",
"text": "Test text",
"priority": "just chill!",
"timestamp": int(round(time.time()))
}

webhook_url = os.environ.get("SLACK_WEBHOOK_URL")
result = slack_message(webhook_url, options)
Expand All @@ -134,7 +139,6 @@ def test_slack_message(self):
result = slack_message(webhook_url, options)
assert result == False


def test_grep(self):
# open current file and try to find this method in it
assert len(grep("test_grep", open(__file__, "r"))) == 2
Expand Down

0 comments on commit ac622ee

Please sign in to comment.