Skip to content

Commit

Permalink
Added volume mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Habush committed Mar 31, 2019
1 parent 7ac4b7a commit 8424d69
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
6 changes: 4 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
try:
MONGODB_URI = os.environ["MONGODB_URI"]
REDIS_URI = os.environ["REDIS_URI"]
DATASET_DIR = os.environ["DATASETS_DIR"]
EXPIRY_SPAN = float(os.environ["EXPIRY_SPAN"]) # the expiration period for a session in days
SCAN_INTERVAL = float(os.environ["SCAN_INTERVAL"])
APP_PORT = os.environ["APP_PORT"]

except KeyError:
MONGODB_URI = "http://localhost:27017"
REDIS_URI = "redis://localhost:6379/0"
DATASET_DIR = "/home/root"
EXPIRY_SPAN = 14
SCAN_INTERVAL = 3600 * 24 # every 24hrs
APP_PORT = 80
Expand All @@ -43,10 +41,14 @@
except KeyError:
MOZI_URI = "http://locahost:8080"

DATASET_DIR = "/opt/moses-service/data"

def setup_logging(default_path='logging.yml', default_level=logging.INFO):
"""Setup logging configuration
"""
LOG_DIR = "/opt/moses-service/log"
if not os.path.exists(LOG_DIR):
os.makedirs(LOG_DIR)
if os.path.exists(default_path):
with open(default_path, 'rt') as f:
config = yaml.safe_load(f.read())
Expand Down
2 changes: 2 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ services:

working_dir: /home/root/mozi_snet_service

volumes:
- $HOME/.mozi/dev:/opt
command: bash -c "circusd --log-level debug circus-dev.ini"

frontend:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:

volumes:
- /etc:/etc
- $HOME/.mozi/prod:/opt

frontend:
build:
Expand Down
4 changes: 2 additions & 2 deletions logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ handlers:
class: logging.handlers.RotatingFileHandler
level: INFO
formatter: simple
filename: info.log
filename: /opt/moses-service/log/info.log
maxBytes: 10485760 # 10MB
backupCount: 20
encoding: utf8
Expand All @@ -32,7 +32,7 @@ handlers:
class: logging.handlers.RotatingFileHandler
level: ERROR
formatter: simple
filename: errors.log
filename: /opt/moses-service/log/errors.log
maxBytes: 10485760 # 10MB
backupCount: 20
encoding: utf8
Expand Down
13 changes: 4 additions & 9 deletions service/moses_service_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
import base64
import sys
import yaml
from config import GRPC_HOST, GRPC_PORT, setup_logging
import logging

setup_logging()

logger = logging.getLogger("client_log")
from config import GRPC_HOST, GRPC_PORT


def read_file(location):
Expand Down Expand Up @@ -45,8 +40,8 @@ def run_analysis(stub, opts_file, file_path):
channel = grpc.insecure_channel(f"{GRPC_HOST}:{GRPC_PORT}")
stub = MosesServiceStub(channel)
result = run_analysis(stub, sys.argv[1], sys.argv[2])
logger.info(result)
print(result)
except grpc.RpcError as e:
logger.error(e.details())
print(e.details())
else:
logger.info(f"Usage: python {__file__} options.yaml <input_file>")
print(f"Usage: python {__file__} options.yaml <input_file>")
2 changes: 2 additions & 0 deletions task/task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def write_dataset(b_string, mnemonic):
:param mnemonic: the mnemonic of the associated session
:return: cwd: the directory where the dataset file is saved
"""
if not os.path.exists(DATASET_DIR):
os.makedirs(DATASET_DIR)
swd = os.path.join(DATASET_DIR, f"session_{mnemonic}")

if not os.path.exists(swd):
Expand Down

0 comments on commit 8424d69

Please sign in to comment.