services

deepdataspace.services

This module wraps all service components for dds and provides a common interface to control them.

celery

deepdataspace.services.celery

The celery service manager.

class Celery[source]

Bases: Service

start()[source]

config

deepdataspace.services.config

This file defines global config variables shared by all services.

log_and_save_env(name: str, value)[source]

Save an export statement to the env file, and log it to the console. The saved statements will be loaded by ddsop command.

load_all_env()[source]

Load environment variables from the env file. The env file is generated by dds command.

save_all_env()[source]
print_if_verbose(*args, **kwargs)[source]

Only print message when VERBOSE_LOG is On.

generate_redis_conf(config_path: str)[source]
setup_redis_password(config_path: str)[source]

Generate a random password in the redis config file

read_redis_password(config_path: str)[source]

Read redis password from config file.

generate_mongodb_conf(config_path: str)[source]
setup_mongodb_password(config_path: str)[source]

Generate a random password for mongodb. It’s not directly used by mongodb server, but read by dds tool to set up the server.

read_mongodb_password(config_path: str)[source]

Read mongodb password from config file.

dds

deepdataspace.services.dds

The dds service manager. This is the main entry point for dds, which controls all other services.

class DDS(*args, **kwargs)[source]

Bases: object

argument_or_config(key, value, default)[source]
exit_or_raise(msg: str)[source]
prefight_checks()[source]
init_samples()[source]
init_envs()[source]

Init all global environments. These environments will be read by subprocesses, especially celery and django.

init()[source]

Make preparations before start the services.

start_db()[source]
start_redis()[source]
start_mongodb()[source]
start_celery()[source]
start_django()[source]
static close_process(pid: int)[source]

Close a process by pid. Try p.terminate first, then p.kill if it survives more than 1 second.

close_all_started()[source]

Close all started subprocesses.

start_all()[source]

Start all services.

greeting()[source]

Print startup messages to the console.

static loop()[source]

Block the main process. Don’t use os.waitpid, it is not Windows compatible.

start()[source]
stop()[source]

django

deepdataspace.services.django

The django service manager.

class Django[source]

Bases: Service

migrate_db()[source]
start()[source]

mongodb

deepdataspace.services.mongodb

The mongodb service manager.

class MongoDB[source]

Bases: Service

start()[source]

redis

deepdataspace.services.redis

The redis service manager.

class Redis[source]

Bases: Service

start()[source]

service

deepdataspace.services.service

Base class and common interfaces for all services.

terminate_all_children(sig, frame)[source]
progress_log(log_prefix: str)[source]

Print a dynamic log message while we start services in the background. So users won’t mistake that our process is dead.

class Service(name: str, cmd_list: list)[source]

Bases: object

static close_process(pid: int)[source]

Close a process by pid. Try p.terminate first, then p.kill if it survives more than 1 second.

clean_process()[source]

Close all process identified by cmd_id

open_process(cmd: list, wait: int = 2)[source]

Start a subprocess with cmd and argument. :param cmd: the cmd and arguments used to start the subprocess :param wait: num of seconds to wait after init the subprocess

check_process()[source]

Check if the process identified by cmd_is is running.

start_process(cmd_list: list, wait: int = 2)[source]

Start a subprocess with the command line arguments. :param cmd_list: the command line arguments to start the process :param cmd_id: the command line identifier, this must be unique enough to identify the process from all processes :param wait: how many seconds to wait after the subprocess is called

sqlite

deepdataspace.services.sqlite

The sqlite db service manager.

class SQLite[source]

Bases: object

We don’t need to ‘start’ sqlite, we just implement this to unify controller API.

start()[source]