repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
bd808/python-iptools
iptools/__init__.py
IpRange.index
def index(self, item): """ Return the 0-based position of `item` in this IpRange. >>> r = IpRange('127.0.0.1', '127.255.255.255') >>> r.index('127.0.0.1') 0 >>> r.index('127.255.255.255') 16777214 >>> r.index('10.0.0.1') Traceback (most recent ca...
python
def index(self, item): """ Return the 0-based position of `item` in this IpRange. >>> r = IpRange('127.0.0.1', '127.255.255.255') >>> r.index('127.0.0.1') 0 >>> r.index('127.255.255.255') 16777214 >>> r.index('10.0.0.1') Traceback (most recent ca...
[ "def", "index", "(", "self", ",", "item", ")", ":", "item", "=", "self", ".", "_cast", "(", "item", ")", "offset", "=", "item", "-", "self", ".", "startIp", "if", "offset", ">=", "0", "and", "offset", "<", "self", ".", "_len", ":", "return", "off...
Return the 0-based position of `item` in this IpRange. >>> r = IpRange('127.0.0.1', '127.255.255.255') >>> r.index('127.0.0.1') 0 >>> r.index('127.255.255.255') 16777214 >>> r.index('10.0.0.1') Traceback (most recent call last): ... ValueErro...
[ "Return", "the", "0", "-", "based", "position", "of", "item", "in", "this", "IpRange", "." ]
5d3fae0056297540355bb7c6c112703cfaa4b6ce
https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/__init__.py#L259-L283
train
torfsen/service
src/service/__init__.py
_detach_process
def _detach_process(): """ Detach daemon process. Forks the current process into a parent and a detached child. The child process resides in its own process group, has no controlling terminal attached and is cleaned up by the init process. Returns ``True`` for the parent and ``False`` for the ...
python
def _detach_process(): """ Detach daemon process. Forks the current process into a parent and a detached child. The child process resides in its own process group, has no controlling terminal attached and is cleaned up by the init process. Returns ``True`` for the parent and ``False`` for the ...
[ "def", "_detach_process", "(", ")", ":", "# To detach from our process group we need to call ``setsid``. We", "# can only do that if we aren't a process group leader. Therefore", "# we fork once, which makes sure that the new child process is not", "# a process group leader.", "pid", "=", "os"...
Detach daemon process. Forks the current process into a parent and a detached child. The child process resides in its own process group, has no controlling terminal attached and is cleaned up by the init process. Returns ``True`` for the parent and ``False`` for the child.
[ "Detach", "daemon", "process", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L49-L78
train
torfsen/service
src/service/__init__.py
_block
def _block(predicate, timeout): """ Block until a predicate becomes true. ``predicate`` is a function taking no arguments. The call to ``_block`` blocks until ``predicate`` returns a true value. This is done by polling ``predicate``. ``timeout`` is either ``True`` (block indefinitely) or a tim...
python
def _block(predicate, timeout): """ Block until a predicate becomes true. ``predicate`` is a function taking no arguments. The call to ``_block`` blocks until ``predicate`` returns a true value. This is done by polling ``predicate``. ``timeout`` is either ``True`` (block indefinitely) or a tim...
[ "def", "_block", "(", "predicate", ",", "timeout", ")", ":", "if", "timeout", ":", "if", "timeout", "is", "True", ":", "timeout", "=", "float", "(", "'Inf'", ")", "timeout", "=", "time", ".", "time", "(", ")", "+", "timeout", "while", "not", "predica...
Block until a predicate becomes true. ``predicate`` is a function taking no arguments. The call to ``_block`` blocks until ``predicate`` returns a true value. This is done by polling ``predicate``. ``timeout`` is either ``True`` (block indefinitely) or a timeout in seconds. The return value i...
[ "Block", "until", "a", "predicate", "becomes", "true", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L143-L163
train
torfsen/service
src/service/__init__.py
_PIDFile.read_pid
def read_pid(self): """ Return the PID of the process owning the lock. Returns ``None`` if no lock is present. """ try: with open(self._path, 'r') as f: s = f.read().strip() if not s: return None ret...
python
def read_pid(self): """ Return the PID of the process owning the lock. Returns ``None`` if no lock is present. """ try: with open(self._path, 'r') as f: s = f.read().strip() if not s: return None ret...
[ "def", "read_pid", "(", "self", ")", ":", "try", ":", "with", "open", "(", "self", ".", "_path", ",", "'r'", ")", "as", "f", ":", "s", "=", "f", ".", "read", "(", ")", ".", "strip", "(", ")", "if", "not", "s", ":", "return", "None", "return",...
Return the PID of the process owning the lock. Returns ``None`` if no lock is present.
[ "Return", "the", "PID", "of", "the", "process", "owning", "the", "lock", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L109-L124
train
torfsen/service
src/service/__init__.py
Service._get_logger_file_handles
def _get_logger_file_handles(self): """ Find the file handles used by our logger's handlers. """ handles = [] for handler in self.logger.handlers: # The following code works for logging's SysLogHandler, # StreamHandler, SocketHandler, and their subclasses....
python
def _get_logger_file_handles(self): """ Find the file handles used by our logger's handlers. """ handles = [] for handler in self.logger.handlers: # The following code works for logging's SysLogHandler, # StreamHandler, SocketHandler, and their subclasses....
[ "def", "_get_logger_file_handles", "(", "self", ")", ":", "handles", "=", "[", "]", "for", "handler", "in", "self", ".", "logger", ".", "handlers", ":", "# The following code works for logging's SysLogHandler,", "# StreamHandler, SocketHandler, and their subclasses.", "for"...
Find the file handles used by our logger's handlers.
[ "Find", "the", "file", "handles", "used", "by", "our", "logger", "s", "handlers", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L221-L237
train
torfsen/service
src/service/__init__.py
Service.is_running
def is_running(self): """ Check if the daemon is running. """ pid = self.get_pid() if pid is None: return False # The PID file may still exist even if the daemon isn't running, # for example if it has crashed. try: os.kill(pid, 0) ...
python
def is_running(self): """ Check if the daemon is running. """ pid = self.get_pid() if pid is None: return False # The PID file may still exist even if the daemon isn't running, # for example if it has crashed. try: os.kill(pid, 0) ...
[ "def", "is_running", "(", "self", ")", ":", "pid", "=", "self", ".", "get_pid", "(", ")", "if", "pid", "is", "None", ":", "return", "False", "# The PID file may still exist even if the daemon isn't running,", "# for example if it has crashed.", "try", ":", "os", "."...
Check if the daemon is running.
[ "Check", "if", "the", "daemon", "is", "running", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L239-L259
train
torfsen/service
src/service/__init__.py
Service._get_signal_event
def _get_signal_event(self, s): ''' Get the event for a signal. Checks if the signal has been enabled and raises a ``ValueError`` if not. ''' try: return self._signal_events[int(s)] except KeyError: raise ValueError('Signal {} has not been...
python
def _get_signal_event(self, s): ''' Get the event for a signal. Checks if the signal has been enabled and raises a ``ValueError`` if not. ''' try: return self._signal_events[int(s)] except KeyError: raise ValueError('Signal {} has not been...
[ "def", "_get_signal_event", "(", "self", ",", "s", ")", ":", "try", ":", "return", "self", ".", "_signal_events", "[", "int", "(", "s", ")", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "'Signal {} has not been enabled'", ".", "format", "(", ...
Get the event for a signal. Checks if the signal has been enabled and raises a ``ValueError`` if not.
[ "Get", "the", "event", "for", "a", "signal", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L267-L277
train
torfsen/service
src/service/__init__.py
Service.send_signal
def send_signal(self, s): """ Send a signal to the daemon process. The signal must have been enabled using the ``signals`` parameter of :py:meth:`Service.__init__`. Otherwise, a ``ValueError`` is raised. """ self._get_signal_event(s) # Check if signal has been e...
python
def send_signal(self, s): """ Send a signal to the daemon process. The signal must have been enabled using the ``signals`` parameter of :py:meth:`Service.__init__`. Otherwise, a ``ValueError`` is raised. """ self._get_signal_event(s) # Check if signal has been e...
[ "def", "send_signal", "(", "self", ",", "s", ")", ":", "self", ".", "_get_signal_event", "(", "s", ")", "# Check if signal has been enabled", "pid", "=", "self", ".", "get_pid", "(", ")", "if", "not", "pid", ":", "raise", "ValueError", "(", "'Daemon is not r...
Send a signal to the daemon process. The signal must have been enabled using the ``signals`` parameter of :py:meth:`Service.__init__`. Otherwise, a ``ValueError`` is raised.
[ "Send", "a", "signal", "to", "the", "daemon", "process", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L279-L291
train
torfsen/service
src/service/__init__.py
Service.stop
def stop(self, block=False): """ Tell the daemon process to stop. Sends the SIGTERM signal to the daemon process, requesting it to terminate. If ``block`` is true then the call blocks until the daemon process has exited. This may take some time since the daemon ...
python
def stop(self, block=False): """ Tell the daemon process to stop. Sends the SIGTERM signal to the daemon process, requesting it to terminate. If ``block`` is true then the call blocks until the daemon process has exited. This may take some time since the daemon ...
[ "def", "stop", "(", "self", ",", "block", "=", "False", ")", ":", "self", ".", "send_signal", "(", "signal", ".", "SIGTERM", ")", "return", "_block", "(", "lambda", ":", "not", "self", ".", "is_running", "(", ")", ",", "block", ")" ]
Tell the daemon process to stop. Sends the SIGTERM signal to the daemon process, requesting it to terminate. If ``block`` is true then the call blocks until the daemon process has exited. This may take some time since the daemon process will complete its on-going backup activit...
[ "Tell", "the", "daemon", "process", "to", "stop", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L381-L401
train
torfsen/service
src/service/__init__.py
Service.kill
def kill(self, block=False): """ Kill the daemon process. Sends the SIGKILL signal to the daemon process, killing it. You probably want to try :py:meth:`stop` first. If ``block`` is true then the call blocks until the daemon process has exited. ``block`` can either be `...
python
def kill(self, block=False): """ Kill the daemon process. Sends the SIGKILL signal to the daemon process, killing it. You probably want to try :py:meth:`stop` first. If ``block`` is true then the call blocks until the daemon process has exited. ``block`` can either be `...
[ "def", "kill", "(", "self", ",", "block", "=", "False", ")", ":", "pid", "=", "self", ".", "get_pid", "(", ")", "if", "not", "pid", ":", "raise", "ValueError", "(", "'Daemon is not running.'", ")", "try", ":", "os", ".", "kill", "(", "pid", ",", "s...
Kill the daemon process. Sends the SIGKILL signal to the daemon process, killing it. You probably want to try :py:meth:`stop` first. If ``block`` is true then the call blocks until the daemon process has exited. ``block`` can either be ``True`` (in which case it blocks indefini...
[ "Kill", "the", "daemon", "process", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L403-L437
train
torfsen/service
src/service/__init__.py
Service.start
def start(self, block=False): """ Start the daemon process. The daemon process is started in the background and the calling process returns. Once the daemon process is initialized it calls the :py:meth:`run` method. If ``block`` is true then the call blocks unt...
python
def start(self, block=False): """ Start the daemon process. The daemon process is started in the background and the calling process returns. Once the daemon process is initialized it calls the :py:meth:`run` method. If ``block`` is true then the call blocks unt...
[ "def", "start", "(", "self", ",", "block", "=", "False", ")", ":", "pid", "=", "self", ".", "get_pid", "(", ")", "if", "pid", ":", "raise", "ValueError", "(", "'Daemon is already running at PID %d.'", "%", "pid", ")", "# The default is to place the PID file into...
Start the daemon process. The daemon process is started in the background and the calling process returns. Once the daemon process is initialized it calls the :py:meth:`run` method. If ``block`` is true then the call blocks until the daemon process has started. ``block...
[ "Start", "the", "daemon", "process", "." ]
d0dd824fce9237825c1943b30cd14f7b0f5957a6
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L439-L544
train
datacats/datacats
datacats/cli/create.py
create
def create(opts): """Create a new environment Usage: datacats create [-bin] [--interactive] [-s NAME] [--address=IP] [--syslog] [--ckan=CKAN_VERSION] [--no-datapusher] [--site-url SITE_URL] [--no-init-db] ENVIRONMENT_DIR [PORT] Options: --address=IP Address to li...
python
def create(opts): """Create a new environment Usage: datacats create [-bin] [--interactive] [-s NAME] [--address=IP] [--syslog] [--ckan=CKAN_VERSION] [--no-datapusher] [--site-url SITE_URL] [--no-init-db] ENVIRONMENT_DIR [PORT] Options: --address=IP Address to li...
[ "def", "create", "(", "opts", ")", ":", "if", "opts", "[", "'--address'", "]", "and", "is_boot2docker", "(", ")", ":", "raise", "DatacatsError", "(", "'Cannot specify address on boot2docker.'", ")", "return", "create_environment", "(", "environment_dir", "=", "opt...
Create a new environment Usage: datacats create [-bin] [--interactive] [-s NAME] [--address=IP] [--syslog] [--ckan=CKAN_VERSION] [--no-datapusher] [--site-url SITE_URL] [--no-init-db] ENVIRONMENT_DIR [PORT] Options: --address=IP Address to listen on (Linux-only) --...
[ "Create", "a", "new", "environment" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/create.py#L23-L63
train
datacats/datacats
datacats/cli/create.py
reset
def reset(environment, opts): """Resets a site to the default state. This will re-initialize the database and recreate the administrator account. Usage: datacats reset [-iyn] [-s NAME] [ENVIRONMENT] Options: -i --interactive Don't detach from the web container -s --site=NAME The site to rese...
python
def reset(environment, opts): """Resets a site to the default state. This will re-initialize the database and recreate the administrator account. Usage: datacats reset [-iyn] [-s NAME] [ENVIRONMENT] Options: -i --interactive Don't detach from the web container -s --site=NAME The site to rese...
[ "def", "reset", "(", "environment", ",", "opts", ")", ":", "# pylint: disable=unused-argument", "if", "not", "opts", "[", "'--yes'", "]", ":", "y_or_n_prompt", "(", "'Reset will remove all data related to the '", "'site {} and recreate the database'", ".", "format", "(", ...
Resets a site to the default state. This will re-initialize the database and recreate the administrator account. Usage: datacats reset [-iyn] [-s NAME] [ENVIRONMENT] Options: -i --interactive Don't detach from the web container -s --site=NAME The site to reset [default: primary] -y --yes ...
[ "Resets", "a", "site", "to", "the", "default", "state", ".", "This", "will", "re", "-", "initialize", "the", "database", "and", "recreate", "the", "administrator", "account", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/create.py#L122-L157
train
datacats/datacats
datacats/cli/create.py
init
def init(opts, no_install=False, quiet=False): """Initialize a purged environment or copied environment directory Usage: datacats init [-in] [--syslog] [-s NAME] [--address=IP] [--interactive] [--site-url SITE_URL] [ENVIRONMENT_DIR [PORT]] [--no-init-db] Options: --address=IP Addres...
python
def init(opts, no_install=False, quiet=False): """Initialize a purged environment or copied environment directory Usage: datacats init [-in] [--syslog] [-s NAME] [--address=IP] [--interactive] [--site-url SITE_URL] [ENVIRONMENT_DIR [PORT]] [--no-init-db] Options: --address=IP Addres...
[ "def", "init", "(", "opts", ",", "no_install", "=", "False", ",", "quiet", "=", "False", ")", ":", "if", "opts", "[", "'--address'", "]", "and", "is_boot2docker", "(", ")", ":", "raise", "DatacatsError", "(", "'Cannot specify address on boot2docker.'", ")", ...
Initialize a purged environment or copied environment directory Usage: datacats init [-in] [--syslog] [-s NAME] [--address=IP] [--interactive] [--site-url SITE_URL] [ENVIRONMENT_DIR [PORT]] [--no-init-db] Options: --address=IP Address to listen on (Linux-only) --interactive ...
[ "Initialize", "a", "purged", "environment", "or", "copied", "environment", "directory" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/create.py#L160-L237
train
datacats/datacats
datacats/cli/create.py
finish_init
def finish_init(environment, start_web, create_sysadmin, log_syslog=False, do_install=True, quiet=False, site_url=None, interactive=False, init_db=True): """ Common parts of create and init: Install, init db, start site, sysadmin """ if not init_db: start_web = Fa...
python
def finish_init(environment, start_web, create_sysadmin, log_syslog=False, do_install=True, quiet=False, site_url=None, interactive=False, init_db=True): """ Common parts of create and init: Install, init db, start site, sysadmin """ if not init_db: start_web = Fa...
[ "def", "finish_init", "(", "environment", ",", "start_web", ",", "create_sysadmin", ",", "log_syslog", "=", "False", ",", "do_install", "=", "True", ",", "quiet", "=", "False", ",", "site_url", "=", "None", ",", "interactive", "=", "False", ",", "init_db", ...
Common parts of create and init: Install, init db, start site, sysadmin
[ "Common", "parts", "of", "create", "and", "init", ":", "Install", "init", "db", "start", "site", "sysadmin" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/create.py#L240-L283
train
datacats/datacats
datacats/userprofile.py
UserProfile.save
def save(self): """ Save profile settings into user profile directory """ config = self.profiledir + '/config' if not isdir(self.profiledir): makedirs(self.profiledir) cp = SafeConfigParser() cp.add_section('ssh') cp.set('ssh', 'private_key',...
python
def save(self): """ Save profile settings into user profile directory """ config = self.profiledir + '/config' if not isdir(self.profiledir): makedirs(self.profiledir) cp = SafeConfigParser() cp.add_section('ssh') cp.set('ssh', 'private_key',...
[ "def", "save", "(", "self", ")", ":", "config", "=", "self", ".", "profiledir", "+", "'/config'", "if", "not", "isdir", "(", "self", ".", "profiledir", ")", ":", "makedirs", "(", "self", ".", "profiledir", ")", "cp", "=", "SafeConfigParser", "(", ")", ...
Save profile settings into user profile directory
[ "Save", "profile", "settings", "into", "user", "profile", "directory" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L60-L75
train
datacats/datacats
datacats/userprofile.py
UserProfile.generate_ssh_key
def generate_ssh_key(self): """ Generate a new ssh private and public key """ web_command( command=["ssh-keygen", "-q", "-t", "rsa", "-N", "", "-C", "datacats generated {0}@{1}".format( getuser(), gethostname()), ...
python
def generate_ssh_key(self): """ Generate a new ssh private and public key """ web_command( command=["ssh-keygen", "-q", "-t", "rsa", "-N", "", "-C", "datacats generated {0}@{1}".format( getuser(), gethostname()), ...
[ "def", "generate_ssh_key", "(", "self", ")", ":", "web_command", "(", "command", "=", "[", "\"ssh-keygen\"", ",", "\"-q\"", ",", "\"-t\"", ",", "\"rsa\"", ",", "\"-N\"", ",", "\"\"", ",", "\"-C\"", ",", "\"datacats generated {0}@{1}\"", ".", "format", "(", "...
Generate a new ssh private and public key
[ "Generate", "a", "new", "ssh", "private", "and", "public", "key" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L77-L87
train
datacats/datacats
datacats/userprofile.py
UserProfile.create
def create(self, environment, target_name): """ Sends "create project" command to the remote server """ remote_server_command( ["ssh", environment.deploy_target, "create", target_name], environment, self, clean_up=True, )
python
def create(self, environment, target_name): """ Sends "create project" command to the remote server """ remote_server_command( ["ssh", environment.deploy_target, "create", target_name], environment, self, clean_up=True, )
[ "def", "create", "(", "self", ",", "environment", ",", "target_name", ")", ":", "remote_server_command", "(", "[", "\"ssh\"", ",", "environment", ".", "deploy_target", ",", "\"create\"", ",", "target_name", "]", ",", "environment", ",", "self", ",", "clean_up"...
Sends "create project" command to the remote server
[ "Sends", "create", "project", "command", "to", "the", "remote", "server" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L127-L135
train
datacats/datacats
datacats/userprofile.py
UserProfile.admin_password
def admin_password(self, environment, target_name, password): """ Return True if password was set successfully """ try: remote_server_command( ["ssh", environment.deploy_target, "admin_password", target_name, password], envi...
python
def admin_password(self, environment, target_name, password): """ Return True if password was set successfully """ try: remote_server_command( ["ssh", environment.deploy_target, "admin_password", target_name, password], envi...
[ "def", "admin_password", "(", "self", ",", "environment", ",", "target_name", ",", "password", ")", ":", "try", ":", "remote_server_command", "(", "[", "\"ssh\"", ",", "environment", ".", "deploy_target", ",", "\"admin_password\"", ",", "target_name", ",", "pass...
Return True if password was set successfully
[ "Return", "True", "if", "password", "was", "set", "successfully" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L137-L150
train
datacats/datacats
datacats/userprofile.py
UserProfile.deploy
def deploy(self, environment, target_name, stream_output=None): """ Return True if deployment was successful """ try: remote_server_command( [ "rsync", "-lrv", "--safe-links", "--munge-links", "--delete", "--inplace", "-...
python
def deploy(self, environment, target_name, stream_output=None): """ Return True if deployment was successful """ try: remote_server_command( [ "rsync", "-lrv", "--safe-links", "--munge-links", "--delete", "--inplace", "-...
[ "def", "deploy", "(", "self", ",", "environment", ",", "target_name", ",", "stream_output", "=", "None", ")", ":", "try", ":", "remote_server_command", "(", "[", "\"rsync\"", ",", "\"-lrv\"", ",", "\"--safe-links\"", ",", "\"--munge-links\"", ",", "\"--delete\""...
Return True if deployment was successful
[ "Return", "True", "if", "deployment", "was", "successful" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L152-L195
train
Britefury/batchup
batchup/sampling.py
num_batches
def num_batches(n, batch_size): """Compute the number of mini-batches required to cover a data set of size `n` using batches of size `batch_size`. Parameters ---------- n: int the number of samples in the data set batch_size: int the mini-batch size Returns ------- ...
python
def num_batches(n, batch_size): """Compute the number of mini-batches required to cover a data set of size `n` using batches of size `batch_size`. Parameters ---------- n: int the number of samples in the data set batch_size: int the mini-batch size Returns ------- ...
[ "def", "num_batches", "(", "n", ",", "batch_size", ")", ":", "b", "=", "n", "//", "batch_size", "if", "n", "%", "batch_size", ">", "0", ":", "b", "+=", "1", "return", "b" ]
Compute the number of mini-batches required to cover a data set of size `n` using batches of size `batch_size`. Parameters ---------- n: int the number of samples in the data set batch_size: int the mini-batch size Returns ------- int: the number of batches required
[ "Compute", "the", "number", "of", "mini", "-", "batches", "required", "to", "cover", "a", "data", "set", "of", "size", "n", "using", "batches", "of", "size", "batch_size", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L10-L28
train
Britefury/batchup
batchup/sampling.py
StandardSampler.num_indices_generated
def num_indices_generated(self): """ Get the number of indices that would be generated by this sampler. Returns ------- int, `np.inf` or `None`. An int if the number of samples is known, `np.inf` if it is infinite or `None` if the number of sample...
python
def num_indices_generated(self): """ Get the number of indices that would be generated by this sampler. Returns ------- int, `np.inf` or `None`. An int if the number of samples is known, `np.inf` if it is infinite or `None` if the number of sample...
[ "def", "num_indices_generated", "(", "self", ")", ":", "if", "self", ".", "repeats", "==", "-", "1", ":", "return", "np", ".", "inf", "else", ":", "return", "self", ".", "length", "*", "self", ".", "repeats" ]
Get the number of indices that would be generated by this sampler. Returns ------- int, `np.inf` or `None`. An int if the number of samples is known, `np.inf` if it is infinite or `None` if the number of samples is unknown.
[ "Get", "the", "number", "of", "indices", "that", "would", "be", "generated", "by", "this", "sampler", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L137-L151
train
Britefury/batchup
batchup/sampling.py
StandardSampler.in_order_indices_batch_iterator
def in_order_indices_batch_iterator(self, batch_size): """ Create an iterator that generates in-order mini-batches of sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are not enough samples left to fi...
python
def in_order_indices_batch_iterator(self, batch_size): """ Create an iterator that generates in-order mini-batches of sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are not enough samples left to fi...
[ "def", "in_order_indices_batch_iterator", "(", "self", ",", "batch_size", ")", ":", "if", "self", ".", "repeats", "==", "1", ":", "for", "i", "in", "range", "(", "0", ",", "self", ".", "length", ",", "batch_size", ")", ":", "yield", "np", ".", "arange"...
Create an iterator that generates in-order mini-batches of sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are not enough samples left to fill it. The generated mini-batches indices take the form of 1D NumP...
[ "Create", "an", "iterator", "that", "generates", "in", "-", "order", "mini", "-", "batches", "of", "sample", "indices", ".", "The", "batches", "will", "have", "batch_size", "elements", "with", "the", "exception", "of", "the", "final", "batch", "which", "will...
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L153-L225
train
Britefury/batchup
batchup/sampling.py
StandardSampler.shuffled_indices_batch_iterator
def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng): """ Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are not eno...
python
def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng): """ Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are not eno...
[ "def", "shuffled_indices_batch_iterator", "(", "self", ",", "batch_size", ",", "shuffle_rng", ")", ":", "if", "self", ".", "repeats", "==", "1", ":", "indices", "=", "shuffle_rng", ".", "permutation", "(", "self", ".", "length", ")", "for", "i", "in", "ran...
Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements, with the exception of the final batch which will have less if there are not enough samples left to fill it. The generated mini-batches indices take the form o...
[ "Create", "an", "iterator", "that", "generates", "randomly", "shuffled", "mini", "-", "batches", "of", "sample", "indices", ".", "The", "batches", "will", "have", "batch_size", "elements", "with", "the", "exception", "of", "the", "final", "batch", "which", "wi...
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L227-L287
train
Britefury/batchup
batchup/sampling.py
WeightedSampler.shuffled_indices_batch_iterator
def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng): """ Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements. The generated mini-batches indices take the form of 1D NumPy integer arrays. ...
python
def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng): """ Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements. The generated mini-batches indices take the form of 1D NumPy integer arrays. ...
[ "def", "shuffled_indices_batch_iterator", "(", "self", ",", "batch_size", ",", "shuffle_rng", ")", ":", "while", "True", ":", "yield", "shuffle_rng", ".", "choice", "(", "len", "(", "self", ".", "weights", ")", ",", "size", "=", "(", "batch_size", ",", ")"...
Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements. The generated mini-batches indices take the form of 1D NumPy integer arrays. Parameters ---------- batch_size: int Mini-batch siz...
[ "Create", "an", "iterator", "that", "generates", "randomly", "shuffled", "mini", "-", "batches", "of", "sample", "indices", ".", "The", "batches", "will", "have", "batch_size", "elements", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L533-L556
train
Britefury/batchup
batchup/sampling.py
WeightedSampler.class_balancing_sample_weights
def class_balancing_sample_weights(y): """ Compute sample weight given an array of sample classes. The weights are assigned on a per-class basis and the per-class weights are inversely proportional to their frequency. Parameters ---------- y: NumPy array, 1D dtyp...
python
def class_balancing_sample_weights(y): """ Compute sample weight given an array of sample classes. The weights are assigned on a per-class basis and the per-class weights are inversely proportional to their frequency. Parameters ---------- y: NumPy array, 1D dtyp...
[ "def", "class_balancing_sample_weights", "(", "y", ")", ":", "h", "=", "np", ".", "bincount", "(", "y", ")", "cls_weight", "=", "1.0", "/", "(", "h", ".", "astype", "(", "float", ")", "*", "len", "(", "np", ".", "nonzero", "(", "h", ")", "[", "0"...
Compute sample weight given an array of sample classes. The weights are assigned on a per-class basis and the per-class weights are inversely proportional to their frequency. Parameters ---------- y: NumPy array, 1D dtype=int sample classes, values must be 0 or posit...
[ "Compute", "sample", "weight", "given", "an", "array", "of", "sample", "classes", ".", "The", "weights", "are", "assigned", "on", "a", "per", "-", "class", "basis", "and", "the", "per", "-", "class", "weights", "are", "inversely", "proportional", "to", "th...
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L559-L579
train
Britefury/batchup
batchup/sampling.py
WeightedSubsetSampler.shuffled_indices_batch_iterator
def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng): """ Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements. The generated mini-batches indices take the form of 1D NumPy integer arrays. ...
python
def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng): """ Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements. The generated mini-batches indices take the form of 1D NumPy integer arrays. ...
[ "def", "shuffled_indices_batch_iterator", "(", "self", ",", "batch_size", ",", "shuffle_rng", ")", ":", "while", "True", ":", "yield", "shuffle_rng", ".", "choice", "(", "self", ".", "indices", ",", "size", "=", "(", "batch_size", ",", ")", ",", "p", "=", ...
Create an iterator that generates randomly shuffled mini-batches of sample indices. The batches will have `batch_size` elements. The generated mini-batches indices take the form of 1D NumPy integer arrays. Parameters ---------- batch_size: int Mini-batch siz...
[ "Create", "an", "iterator", "that", "generates", "randomly", "shuffled", "mini", "-", "batches", "of", "sample", "indices", ".", "The", "batches", "will", "have", "batch_size", "elements", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L688-L711
train
Britefury/batchup
batchup/sampling.py
WeightedSubsetSampler.class_balancing_sampler
def class_balancing_sampler(y, indices): """ Construct a `WeightedSubsetSampler` that compensates for class imbalance. Parameters ---------- y: NumPy array, 1D dtype=int sample classes, values must be 0 or positive indices: NumPy array, 1D dtype=int ...
python
def class_balancing_sampler(y, indices): """ Construct a `WeightedSubsetSampler` that compensates for class imbalance. Parameters ---------- y: NumPy array, 1D dtype=int sample classes, values must be 0 or positive indices: NumPy array, 1D dtype=int ...
[ "def", "class_balancing_sampler", "(", "y", ",", "indices", ")", ":", "weights", "=", "WeightedSampler", ".", "class_balancing_sample_weights", "(", "y", "[", "indices", "]", ")", "return", "WeightedSubsetSampler", "(", "weights", ",", "indices", "=", "indices", ...
Construct a `WeightedSubsetSampler` that compensates for class imbalance. Parameters ---------- y: NumPy array, 1D dtype=int sample classes, values must be 0 or positive indices: NumPy array, 1D dtype=int An array of indices that identify the subset of sa...
[ "Construct", "a", "WeightedSubsetSampler", "that", "compensates", "for", "class", "imbalance", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L714-L733
train
datacats/datacats
datacats/network.py
wait_for_service_available
def wait_for_service_available(container, url, timeout): """ Wait up to timeout seconds for service at host:port to start. Returns True if service becomes available, False if the container stops or raises ServiceTimeout if timeout is reached. """ start = time.time() remaining = time...
python
def wait_for_service_available(container, url, timeout): """ Wait up to timeout seconds for service at host:port to start. Returns True if service becomes available, False if the container stops or raises ServiceTimeout if timeout is reached. """ start = time.time() remaining = time...
[ "def", "wait_for_service_available", "(", "container", ",", "url", ",", "timeout", ")", ":", "start", "=", "time", ".", "time", "(", ")", "remaining", "=", "timeout", "while", "True", ":", "remaining", "=", "start", "+", "timeout", "-", "time", ".", "tim...
Wait up to timeout seconds for service at host:port to start. Returns True if service becomes available, False if the container stops or raises ServiceTimeout if timeout is reached.
[ "Wait", "up", "to", "timeout", "seconds", "for", "service", "at", "host", ":", "port", "to", "start", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/network.py#L21-L51
train
Britefury/batchup
batchup/config.py
get_data_path
def get_data_path(filename): """ Get the path of the given file within the batchup data directory Parameters ---------- filename: str The filename to locate within the batchup data directory Returns ------- str The full path of the file """ if os.path.isabs(file...
python
def get_data_path(filename): """ Get the path of the given file within the batchup data directory Parameters ---------- filename: str The filename to locate within the batchup data directory Returns ------- str The full path of the file """ if os.path.isabs(file...
[ "def", "get_data_path", "(", "filename", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "filename", ")", ":", "return", "filename", "else", ":", "return", "os", ".", "path", ".", "join", "(", "get_data_dir", "(", ")", ",", "filename", ")" ]
Get the path of the given file within the batchup data directory Parameters ---------- filename: str The filename to locate within the batchup data directory Returns ------- str The full path of the file
[ "Get", "the", "path", "of", "the", "given", "file", "within", "the", "batchup", "data", "directory" ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L68-L85
train
Britefury/batchup
batchup/config.py
download
def download(path, source_url): """ Download a file to a given path from a given URL, if it does not exist. Parameters ---------- path: str The (destination) path of the file on the local filesystem source_url: str The URL from which to download the file Returns -------...
python
def download(path, source_url): """ Download a file to a given path from a given URL, if it does not exist. Parameters ---------- path: str The (destination) path of the file on the local filesystem source_url: str The URL from which to download the file Returns -------...
[ "def", "download", "(", "path", ",", "source_url", ")", ":", "dir_path", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "dir_path", ")", ":", "os", ".", "makedirs", "(", "dir_path", ")"...
Download a file to a given path from a given URL, if it does not exist. Parameters ---------- path: str The (destination) path of the file on the local filesystem source_url: str The URL from which to download the file Returns ------- str The path of the file
[ "Download", "a", "file", "to", "a", "given", "path", "from", "a", "given", "URL", "if", "it", "does", "not", "exist", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L88-L124
train
Britefury/batchup
batchup/config.py
compute_sha256
def compute_sha256(path): """ Compute the SHA-256 hash of the file at the given path Parameters ---------- path: str The path of the file Returns ------- str The SHA-256 HEX digest """ hasher = hashlib.sha256() with open(path, 'rb') as f: # 10MB chun...
python
def compute_sha256(path): """ Compute the SHA-256 hash of the file at the given path Parameters ---------- path: str The path of the file Returns ------- str The SHA-256 HEX digest """ hasher = hashlib.sha256() with open(path, 'rb') as f: # 10MB chun...
[ "def", "compute_sha256", "(", "path", ")", ":", "hasher", "=", "hashlib", ".", "sha256", "(", ")", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "# 10MB chunks", "for", "chunk", "in", "iter", "(", "lambda", ":", "f", ".", "read", "...
Compute the SHA-256 hash of the file at the given path Parameters ---------- path: str The path of the file Returns ------- str The SHA-256 HEX digest
[ "Compute", "the", "SHA", "-", "256", "hash", "of", "the", "file", "at", "the", "given", "path" ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L127-L146
train
Britefury/batchup
batchup/config.py
verify_file
def verify_file(path, sha256): """ Verify the integrity of a file by checking its SHA-256 hash. If no digest is supplied, the digest is printed to the console. Closely follows the code in `torchvision.datasets.utils.check_integrity` Parameters ---------- path: str The path of the f...
python
def verify_file(path, sha256): """ Verify the integrity of a file by checking its SHA-256 hash. If no digest is supplied, the digest is printed to the console. Closely follows the code in `torchvision.datasets.utils.check_integrity` Parameters ---------- path: str The path of the f...
[ "def", "verify_file", "(", "path", ",", "sha256", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "return", "False", "digest", "=", "compute_sha256", "(", "path", ")", "if", "sha256", "is", "None", ":", "# No digest supp...
Verify the integrity of a file by checking its SHA-256 hash. If no digest is supplied, the digest is printed to the console. Closely follows the code in `torchvision.datasets.utils.check_integrity` Parameters ---------- path: str The path of the file to check sha256: str The ex...
[ "Verify", "the", "integrity", "of", "a", "file", "by", "checking", "its", "SHA", "-", "256", "hash", ".", "If", "no", "digest", "is", "supplied", "the", "digest", "is", "printed", "to", "the", "console", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L149-L180
train
Britefury/batchup
batchup/config.py
download_and_verify
def download_and_verify(path, source_url, sha256): """ Download a file to a given path from a given URL, if it does not exist. After downloading it, verify it integrity by checking the SHA-256 hash. Parameters ---------- path: str The (destination) path of the file on the local filesyst...
python
def download_and_verify(path, source_url, sha256): """ Download a file to a given path from a given URL, if it does not exist. After downloading it, verify it integrity by checking the SHA-256 hash. Parameters ---------- path: str The (destination) path of the file on the local filesyst...
[ "def", "download_and_verify", "(", "path", ",", "source_url", ",", "sha256", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "# Already exists?", "# Nothing to do, except print the SHA-256 if necessary", "if", "sha256", "is", "None", ":", ...
Download a file to a given path from a given URL, if it does not exist. After downloading it, verify it integrity by checking the SHA-256 hash. Parameters ---------- path: str The (destination) path of the file on the local filesystem source_url: str The URL from which to download t...
[ "Download", "a", "file", "to", "a", "given", "path", "from", "a", "given", "URL", "if", "it", "does", "not", "exist", ".", "After", "downloading", "it", "verify", "it", "integrity", "by", "checking", "the", "SHA", "-", "256", "hash", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L183-L244
train
Britefury/batchup
batchup/config.py
copy_and_verify
def copy_and_verify(path, source_path, sha256): """ Copy a file to a given path from a given path, if it does not exist. After copying it, verify it integrity by checking the SHA-256 hash. Parameters ---------- path: str The (destination) path of the file on the local filesystem sou...
python
def copy_and_verify(path, source_path, sha256): """ Copy a file to a given path from a given path, if it does not exist. After copying it, verify it integrity by checking the SHA-256 hash. Parameters ---------- path: str The (destination) path of the file on the local filesystem sou...
[ "def", "copy_and_verify", "(", "path", ",", "source_path", ",", "sha256", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "# Already exists?", "# Nothing to do, except print the SHA-256 if necessary", "if", "sha256", "is", "None", ":", "...
Copy a file to a given path from a given path, if it does not exist. After copying it, verify it integrity by checking the SHA-256 hash. Parameters ---------- path: str The (destination) path of the file on the local filesystem source_path: str The path from which to copy the file ...
[ "Copy", "a", "file", "to", "a", "given", "path", "from", "a", "given", "path", "if", "it", "does", "not", "exist", ".", "After", "copying", "it", "verify", "it", "integrity", "by", "checking", "the", "SHA", "-", "256", "hash", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L247-L298
train
datacats/datacats
datacats/template.py
ckan_extension_template
def ckan_extension_template(name, target): """ Create ckanext-(name) in target directory. """ setupdir = '{0}/ckanext-{1}theme'.format(target, name) extdir = setupdir + '/ckanext/{0}theme'.format(name) templatedir = extdir + '/templates/' staticdir = extdir + '/static/datacats' makedirs...
python
def ckan_extension_template(name, target): """ Create ckanext-(name) in target directory. """ setupdir = '{0}/ckanext-{1}theme'.format(target, name) extdir = setupdir + '/ckanext/{0}theme'.format(name) templatedir = extdir + '/templates/' staticdir = extdir + '/static/datacats' makedirs...
[ "def", "ckan_extension_template", "(", "name", ",", "target", ")", ":", "setupdir", "=", "'{0}/ckanext-{1}theme'", ".", "format", "(", "target", ",", "name", ")", "extdir", "=", "setupdir", "+", "'/ckanext/{0}theme'", ".", "format", "(", "name", ")", "template...
Create ckanext-(name) in target directory.
[ "Create", "ckanext", "-", "(", "name", ")", "in", "target", "directory", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/template.py#L12-L41
train
datacats/datacats
datacats/cli/shell.py
shell
def shell(environment, opts): """Run a command or interactive shell within this environment Usage: datacats [-d] [-s NAME] shell [ENVIRONMENT [COMMAND...]] Options: -d --detach Run the resulting container in the background -s --site=NAME Specify a site to run the shell on [default: primary] ENVIRON...
python
def shell(environment, opts): """Run a command or interactive shell within this environment Usage: datacats [-d] [-s NAME] shell [ENVIRONMENT [COMMAND...]] Options: -d --detach Run the resulting container in the background -s --site=NAME Specify a site to run the shell on [default: primary] ENVIRON...
[ "def", "shell", "(", "environment", ",", "opts", ")", ":", "environment", ".", "require_data", "(", ")", "environment", ".", "start_supporting_containers", "(", ")", "return", "environment", ".", "interactive_shell", "(", "opts", "[", "'COMMAND'", "]", ",", "d...
Run a command or interactive shell within this environment Usage: datacats [-d] [-s NAME] shell [ENVIRONMENT [COMMAND...]] Options: -d --detach Run the resulting container in the background -s --site=NAME Specify a site to run the shell on [default: primary] ENVIRONMENT may be an environment name or a ...
[ "Run", "a", "command", "or", "interactive", "shell", "within", "this", "environment" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/shell.py#L10-L28
train
datacats/datacats
datacats/cli/shell.py
paster
def paster(opts): """Run a paster command from the current directory Usage: datacats paster [-d] [-s NAME] [COMMAND...] Options: -s --site=NAME Specify a site to run this paster command on [default: primary] -d --detach Run the resulting container in the background You must be inside a datacats env...
python
def paster(opts): """Run a paster command from the current directory Usage: datacats paster [-d] [-s NAME] [COMMAND...] Options: -s --site=NAME Specify a site to run this paster command on [default: primary] -d --detach Run the resulting container in the background You must be inside a datacats env...
[ "def", "paster", "(", "opts", ")", ":", "environment", "=", "Environment", ".", "load", "(", "'.'", ")", "environment", ".", "require_data", "(", ")", "environment", ".", "start_supporting_containers", "(", ")", "if", "not", "opts", "[", "'COMMAND'", "]", ...
Run a paster command from the current directory Usage: datacats paster [-d] [-s NAME] [COMMAND...] Options: -s --site=NAME Specify a site to run this paster command on [default: primary] -d --detach Run the resulting container in the background You must be inside a datacats environment to run this. The...
[ "Run", "a", "paster", "command", "from", "the", "current", "directory" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/shell.py#L31-L57
train
datacats/datacats
datacats/task.py
save_new_site
def save_new_site(site_name, sitedir, srcdir, port, address, site_url, passwords): """ Add a site's configuration to the source dir and site dir """ cp = ConfigParser.SafeConfigParser() cp.read([srcdir + '/.datacats-environment']) section_name = 'site_' + site_name if not cp.has_se...
python
def save_new_site(site_name, sitedir, srcdir, port, address, site_url, passwords): """ Add a site's configuration to the source dir and site dir """ cp = ConfigParser.SafeConfigParser() cp.read([srcdir + '/.datacats-environment']) section_name = 'site_' + site_name if not cp.has_se...
[ "def", "save_new_site", "(", "site_name", ",", "sitedir", ",", "srcdir", ",", "port", ",", "address", ",", "site_url", ",", "passwords", ")", ":", "cp", "=", "ConfigParser", ".", "SafeConfigParser", "(", ")", "cp", ".", "read", "(", "[", "srcdir", "+", ...
Add a site's configuration to the source dir and site dir
[ "Add", "a", "site", "s", "configuration", "to", "the", "source", "dir", "and", "site", "dir" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L44-L75
train
datacats/datacats
datacats/task.py
save_new_environment
def save_new_environment(name, datadir, srcdir, ckan_version, deploy_target=None, always_prod=False): """ Save an environment's configuration to the source dir and data dir """ with open(datadir + '/.version', 'w') as f: f.write('2') cp = ConfigParser.SafeConfigParser() cp.read...
python
def save_new_environment(name, datadir, srcdir, ckan_version, deploy_target=None, always_prod=False): """ Save an environment's configuration to the source dir and data dir """ with open(datadir + '/.version', 'w') as f: f.write('2') cp = ConfigParser.SafeConfigParser() cp.read...
[ "def", "save_new_environment", "(", "name", ",", "datadir", ",", "srcdir", ",", "ckan_version", ",", "deploy_target", "=", "None", ",", "always_prod", "=", "False", ")", ":", "with", "open", "(", "datadir", "+", "'/.version'", ",", "'w'", ")", "as", "f", ...
Save an environment's configuration to the source dir and data dir
[ "Save", "an", "environment", "s", "configuration", "to", "the", "source", "dir", "and", "data", "dir" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L78-L106
train
datacats/datacats
datacats/task.py
find_environment_dirs
def find_environment_dirs(environment_name=None, data_only=False): """ :param environment_name: exising environment name, path or None to look in current or parent directories for project returns (srcdir, extension_dir, datadir) extension_dir is the name of extension directory user was in/ref...
python
def find_environment_dirs(environment_name=None, data_only=False): """ :param environment_name: exising environment name, path or None to look in current or parent directories for project returns (srcdir, extension_dir, datadir) extension_dir is the name of extension directory user was in/ref...
[ "def", "find_environment_dirs", "(", "environment_name", "=", "None", ",", "data_only", "=", "False", ")", ":", "docker", ".", "require_images", "(", ")", "if", "environment_name", "is", "None", ":", "environment_name", "=", "'.'", "extension_dir", "=", "'ckan'"...
:param environment_name: exising environment name, path or None to look in current or parent directories for project returns (srcdir, extension_dir, datadir) extension_dir is the name of extension directory user was in/referenced, default: 'ckan'. This value is used by the paster cli command. ...
[ ":", "param", "environment_name", ":", "exising", "environment", "name", "path", "or", "None", "to", "look", "in", "current", "or", "parent", "directories", "for", "project" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L118-L170
train
datacats/datacats
datacats/task.py
load_environment
def load_environment(srcdir, datadir=None, allow_old=False): """ Load configuration values for an environment :param srcdir: environment source directory :param datadir: environment data direcory, if None will be discovered from srcdir :param allow_old: Don't throw an exception ...
python
def load_environment(srcdir, datadir=None, allow_old=False): """ Load configuration values for an environment :param srcdir: environment source directory :param datadir: environment data direcory, if None will be discovered from srcdir :param allow_old: Don't throw an exception ...
[ "def", "load_environment", "(", "srcdir", ",", "datadir", "=", "None", ",", "allow_old", "=", "False", ")", ":", "cp", "=", "ConfigParser", ".", "SafeConfigParser", "(", ")", "try", ":", "cp", ".", "read", "(", "[", "srcdir", "+", "'/.datacats-environment'...
Load configuration values for an environment :param srcdir: environment source directory :param datadir: environment data direcory, if None will be discovered from srcdir :param allow_old: Don't throw an exception if this is an old site This is only valid for sites...
[ "Load", "configuration", "values", "for", "an", "environment" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L173-L247
train
datacats/datacats
datacats/task.py
load_site
def load_site(srcdir, datadir, site_name=None): """ Load configuration values for a site. Returns (port, address, site_url, passwords) """ if site_name is None: site_name = 'primary' if not validate.valid_name(site_name): raise DatacatsError('{} is not a valid site name.'.format...
python
def load_site(srcdir, datadir, site_name=None): """ Load configuration values for a site. Returns (port, address, site_url, passwords) """ if site_name is None: site_name = 'primary' if not validate.valid_name(site_name): raise DatacatsError('{} is not a valid site name.'.format...
[ "def", "load_site", "(", "srcdir", ",", "datadir", ",", "site_name", "=", "None", ")", ":", "if", "site_name", "is", "None", ":", "site_name", "=", "'primary'", "if", "not", "validate", ".", "valid_name", "(", "site_name", ")", ":", "raise", "DatacatsError...
Load configuration values for a site. Returns (port, address, site_url, passwords)
[ "Load", "configuration", "values", "for", "a", "site", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L250-L292
train
datacats/datacats
datacats/task.py
new_environment_check
def new_environment_check(srcpath, site_name, ckan_version): """ Check if a new environment or site can be created at the given path. Returns (name, datadir, sitedir, srcdir) or raises DatacatsError """ docker.require_images() workdir, name = path.split(path.abspath(path.expanduser(srcpath))) ...
python
def new_environment_check(srcpath, site_name, ckan_version): """ Check if a new environment or site can be created at the given path. Returns (name, datadir, sitedir, srcdir) or raises DatacatsError """ docker.require_images() workdir, name = path.split(path.abspath(path.expanduser(srcpath))) ...
[ "def", "new_environment_check", "(", "srcpath", ",", "site_name", ",", "ckan_version", ")", ":", "docker", ".", "require_images", "(", ")", "workdir", ",", "name", "=", "path", ".", "split", "(", "path", ".", "abspath", "(", "path", ".", "expanduser", "(",...
Check if a new environment or site can be created at the given path. Returns (name, datadir, sitedir, srcdir) or raises DatacatsError
[ "Check", "if", "a", "new", "environment", "or", "site", "can", "be", "created", "at", "the", "given", "path", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L298-L348
train
datacats/datacats
datacats/task.py
data_complete
def data_complete(datadir, sitedir, get_container_name): """ Return True if the directories and containers we're expecting are present in datadir, sitedir and containers """ if any(not path.isdir(sitedir + x) for x in ('/files', '/run', '/solr')): return False if docker.is_b...
python
def data_complete(datadir, sitedir, get_container_name): """ Return True if the directories and containers we're expecting are present in datadir, sitedir and containers """ if any(not path.isdir(sitedir + x) for x in ('/files', '/run', '/solr')): return False if docker.is_b...
[ "def", "data_complete", "(", "datadir", ",", "sitedir", ",", "get_container_name", ")", ":", "if", "any", "(", "not", "path", ".", "isdir", "(", "sitedir", "+", "x", ")", "for", "x", "in", "(", "'/files'", ",", "'/run'", ",", "'/solr'", ")", ")", ":"...
Return True if the directories and containers we're expecting are present in datadir, sitedir and containers
[ "Return", "True", "if", "the", "directories", "and", "containers", "we", "re", "expecting", "are", "present", "in", "datadir", "sitedir", "and", "containers" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L351-L365
train
datacats/datacats
datacats/task.py
create_directories
def create_directories(datadir, sitedir, srcdir=None): """ Create expected directories in datadir, sitedir and optionally srcdir """ # It's possible that the datadir already exists # (we're making a secondary site) if not path.isdir(datadir): os.makedirs(datadir, mode=0o700) try:...
python
def create_directories(datadir, sitedir, srcdir=None): """ Create expected directories in datadir, sitedir and optionally srcdir """ # It's possible that the datadir already exists # (we're making a secondary site) if not path.isdir(datadir): os.makedirs(datadir, mode=0o700) try:...
[ "def", "create_directories", "(", "datadir", ",", "sitedir", ",", "srcdir", "=", "None", ")", ":", "# It's possible that the datadir already exists", "# (we're making a secondary site)", "if", "not", "path", ".", "isdir", "(", "datadir", ")", ":", "os", ".", "makedi...
Create expected directories in datadir, sitedir and optionally srcdir
[ "Create", "expected", "directories", "in", "datadir", "sitedir", "and", "optionally", "srcdir" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L377-L402
train
datacats/datacats
datacats/task.py
create_virtualenv
def create_virtualenv(srcdir, datadir, preload_image, get_container_name): """ Populate venv from preloaded image """ try: if docker.is_boot2docker(): docker.data_only_container( get_container_name('venv'), ['/usr/lib/ckan'], ) ...
python
def create_virtualenv(srcdir, datadir, preload_image, get_container_name): """ Populate venv from preloaded image """ try: if docker.is_boot2docker(): docker.data_only_container( get_container_name('venv'), ['/usr/lib/ckan'], ) ...
[ "def", "create_virtualenv", "(", "srcdir", ",", "datadir", ",", "preload_image", ",", "get_container_name", ")", ":", "try", ":", "if", "docker", ".", "is_boot2docker", "(", ")", ":", "docker", ".", "data_only_container", "(", "get_container_name", "(", "'venv'"...
Populate venv from preloaded image
[ "Populate", "venv", "from", "preloaded", "image" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L405-L442
train
datacats/datacats
datacats/task.py
create_source
def create_source(srcdir, preload_image, datapusher=False): """ Copy ckan source, datapusher source (optional), who.ini and schema.xml from preload image into srcdir """ try: docker.web_command( command='/bin/cp -a /project/ckan /project_target/ckan', rw={srcdir: '/pr...
python
def create_source(srcdir, preload_image, datapusher=False): """ Copy ckan source, datapusher source (optional), who.ini and schema.xml from preload image into srcdir """ try: docker.web_command( command='/bin/cp -a /project/ckan /project_target/ckan', rw={srcdir: '/pr...
[ "def", "create_source", "(", "srcdir", ",", "preload_image", ",", "datapusher", "=", "False", ")", ":", "try", ":", "docker", ".", "web_command", "(", "command", "=", "'/bin/cp -a /project/ckan /project_target/ckan'", ",", "rw", "=", "{", "srcdir", ":", "'/proje...
Copy ckan source, datapusher source (optional), who.ini and schema.xml from preload image into srcdir
[ "Copy", "ckan", "source", "datapusher", "source", "(", "optional", ")", "who", ".", "ini", "and", "schema", ".", "xml", "from", "preload", "image", "into", "srcdir" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L445-L471
train
datacats/datacats
datacats/task.py
start_supporting_containers
def start_supporting_containers(sitedir, srcdir, passwords, get_container_name, extra_containers, log_syslog=False): """ Start all supporting containers (containers required for CKAN to operate) if they aren't already running, along with some extra containers specified by the user """ if...
python
def start_supporting_containers(sitedir, srcdir, passwords, get_container_name, extra_containers, log_syslog=False): """ Start all supporting containers (containers required for CKAN to operate) if they aren't already running, along with some extra containers specified by the user """ if...
[ "def", "start_supporting_containers", "(", "sitedir", ",", "srcdir", ",", "passwords", ",", "get_container_name", ",", "extra_containers", ",", "log_syslog", "=", "False", ")", ":", "if", "docker", ".", "is_boot2docker", "(", ")", ":", "docker", ".", "data_only_...
Start all supporting containers (containers required for CKAN to operate) if they aren't already running, along with some extra containers specified by the user
[ "Start", "all", "supporting", "containers", "(", "containers", "required", "for", "CKAN", "to", "operate", ")", "if", "they", "aren", "t", "already", "running", "along", "with", "some", "extra", "containers", "specified", "by", "the", "user" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L478-L531
train
datacats/datacats
datacats/task.py
stop_supporting_containers
def stop_supporting_containers(get_container_name, extra_containers): """ Stop postgres and solr containers, along with any specified extra containers """ docker.remove_container(get_container_name('postgres')) docker.remove_container(get_container_name('solr')) for container in extra_containers...
python
def stop_supporting_containers(get_container_name, extra_containers): """ Stop postgres and solr containers, along with any specified extra containers """ docker.remove_container(get_container_name('postgres')) docker.remove_container(get_container_name('solr')) for container in extra_containers...
[ "def", "stop_supporting_containers", "(", "get_container_name", ",", "extra_containers", ")", ":", "docker", ".", "remove_container", "(", "get_container_name", "(", "'postgres'", ")", ")", "docker", ".", "remove_container", "(", "get_container_name", "(", "'solr'", "...
Stop postgres and solr containers, along with any specified extra containers
[ "Stop", "postgres", "and", "solr", "containers", "along", "with", "any", "specified", "extra", "containers" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L534-L541
train
datacats/datacats
datacats/task.py
containers_running
def containers_running(get_container_name): """ Return a list of containers tracked by this environment that are running """ running = [] for n in ['web', 'postgres', 'solr', 'datapusher', 'redis']: info = docker.inspect_container(get_container_name(n)) if info and not info['State'][...
python
def containers_running(get_container_name): """ Return a list of containers tracked by this environment that are running """ running = [] for n in ['web', 'postgres', 'solr', 'datapusher', 'redis']: info = docker.inspect_container(get_container_name(n)) if info and not info['State'][...
[ "def", "containers_running", "(", "get_container_name", ")", ":", "running", "=", "[", "]", "for", "n", "in", "[", "'web'", ",", "'postgres'", ",", "'solr'", ",", "'datapusher'", ",", "'redis'", "]", ":", "info", "=", "docker", ".", "inspect_container", "(...
Return a list of containers tracked by this environment that are running
[ "Return", "a", "list", "of", "containers", "tracked", "by", "this", "environment", "that", "are", "running" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L544-L555
train
datacats/datacats
datacats/environment.py
Environment._load_sites
def _load_sites(self): """ Gets the names of all of the sites from the datadir and stores them in self.sites. Also returns this list. """ if not self.sites: self.sites = task.list_sites(self.datadir) return self.sites
python
def _load_sites(self): """ Gets the names of all of the sites from the datadir and stores them in self.sites. Also returns this list. """ if not self.sites: self.sites = task.list_sites(self.datadir) return self.sites
[ "def", "_load_sites", "(", "self", ")", ":", "if", "not", "self", ".", "sites", ":", "self", ".", "sites", "=", "task", ".", "list_sites", "(", "self", ".", "datadir", ")", "return", "self", ".", "sites" ]
Gets the names of all of the sites from the datadir and stores them in self.sites. Also returns this list.
[ "Gets", "the", "names", "of", "all", "of", "the", "sites", "from", "the", "datadir", "and", "stores", "them", "in", "self", ".", "sites", ".", "Also", "returns", "this", "list", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L73-L80
train
datacats/datacats
datacats/environment.py
Environment.save_site
def save_site(self, create=True): """ Save environment settings in the directory that need to be saved even when creating only a new sub-site env. """ self._load_sites() if create: self.sites.append(self.site_name) task.save_new_site(self.site_name, s...
python
def save_site(self, create=True): """ Save environment settings in the directory that need to be saved even when creating only a new sub-site env. """ self._load_sites() if create: self.sites.append(self.site_name) task.save_new_site(self.site_name, s...
[ "def", "save_site", "(", "self", ",", "create", "=", "True", ")", ":", "self", ".", "_load_sites", "(", ")", "if", "create", ":", "self", ".", "sites", ".", "append", "(", "self", ".", "site_name", ")", "task", ".", "save_new_site", "(", "self", ".",...
Save environment settings in the directory that need to be saved even when creating only a new sub-site env.
[ "Save", "environment", "settings", "in", "the", "directory", "that", "need", "to", "be", "saved", "even", "when", "creating", "only", "a", "new", "sub", "-", "site", "env", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L82-L92
train
datacats/datacats
datacats/environment.py
Environment.save
def save(self): """ Save environment settings into environment directory, overwriting any existing configuration and discarding site config """ task.save_new_environment(self.name, self.datadir, self.target, self.ckan_version, self.deploy_target, self.always_prod)
python
def save(self): """ Save environment settings into environment directory, overwriting any existing configuration and discarding site config """ task.save_new_environment(self.name, self.datadir, self.target, self.ckan_version, self.deploy_target, self.always_prod)
[ "def", "save", "(", "self", ")", ":", "task", ".", "save_new_environment", "(", "self", ".", "name", ",", "self", ".", "datadir", ",", "self", ".", "target", ",", "self", ".", "ckan_version", ",", "self", ".", "deploy_target", ",", "self", ".", "always...
Save environment settings into environment directory, overwriting any existing configuration and discarding site config
[ "Save", "environment", "settings", "into", "environment", "directory", "overwriting", "any", "existing", "configuration", "and", "discarding", "site", "config" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L94-L100
train
datacats/datacats
datacats/environment.py
Environment.new
def new(cls, path, ckan_version, site_name, **kwargs): """ Return a Environment object with settings for a new project. No directories or containers are created by this call. :params path: location for new project directory, may be relative :params ckan_version: release of CKAN ...
python
def new(cls, path, ckan_version, site_name, **kwargs): """ Return a Environment object with settings for a new project. No directories or containers are created by this call. :params path: location for new project directory, may be relative :params ckan_version: release of CKAN ...
[ "def", "new", "(", "cls", ",", "path", ",", "ckan_version", ",", "site_name", ",", "*", "*", "kwargs", ")", ":", "if", "ckan_version", "==", "'master'", ":", "ckan_version", "=", "'latest'", "name", ",", "datadir", ",", "srcdir", "=", "task", ".", "new...
Return a Environment object with settings for a new project. No directories or containers are created by this call. :params path: location for new project directory, may be relative :params ckan_version: release of CKAN to install :params site_name: The name of the site to install datab...
[ "Return", "a", "Environment", "object", "with", "settings", "for", "a", "new", "project", ".", "No", "directories", "or", "containers", "are", "created", "by", "this", "call", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L103-L123
train
datacats/datacats
datacats/environment.py
Environment.load
def load(cls, environment_name=None, site_name='primary', data_only=False, allow_old=False): """ Return an Environment object based on an existing environnment+site. :param environment_name: exising environment name, path or None to look in current or parent directories for project ...
python
def load(cls, environment_name=None, site_name='primary', data_only=False, allow_old=False): """ Return an Environment object based on an existing environnment+site. :param environment_name: exising environment name, path or None to look in current or parent directories for project ...
[ "def", "load", "(", "cls", ",", "environment_name", "=", "None", ",", "site_name", "=", "'primary'", ",", "data_only", "=", "False", ",", "allow_old", "=", "False", ")", ":", "srcdir", ",", "extension_dir", ",", "datadir", "=", "task", ".", "find_environme...
Return an Environment object based on an existing environnment+site. :param environment_name: exising environment name, path or None to look in current or parent directories for project :param data_only: set to True to only load from data dir, not the project dir; Used for purgi...
[ "Return", "an", "Environment", "object", "based", "on", "an", "existing", "environnment", "+", "site", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L126-L168
train
datacats/datacats
datacats/environment.py
Environment.data_complete
def data_complete(self): """ Return True if all the expected datadir files are present """ return task.data_complete(self.datadir, self.sitedir, self._get_container_name)
python
def data_complete(self): """ Return True if all the expected datadir files are present """ return task.data_complete(self.datadir, self.sitedir, self._get_container_name)
[ "def", "data_complete", "(", "self", ")", ":", "return", "task", ".", "data_complete", "(", "self", ".", "datadir", ",", "self", ".", "sitedir", ",", "self", ".", "_get_container_name", ")" ]
Return True if all the expected datadir files are present
[ "Return", "True", "if", "all", "the", "expected", "datadir", "files", "are", "present" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L182-L187
train
datacats/datacats
datacats/environment.py
Environment.require_data
def require_data(self): """ raise a DatacatsError if the datadir or volumes are missing or damaged """ files = task.source_missing(self.target) if files: raise DatacatsError('Missing files in source directory:\n' + '\n'.join(files)) ...
python
def require_data(self): """ raise a DatacatsError if the datadir or volumes are missing or damaged """ files = task.source_missing(self.target) if files: raise DatacatsError('Missing files in source directory:\n' + '\n'.join(files)) ...
[ "def", "require_data", "(", "self", ")", ":", "files", "=", "task", ".", "source_missing", "(", "self", ".", "target", ")", "if", "files", ":", "raise", "DatacatsError", "(", "'Missing files in source directory:\\n'", "+", "'\\n'", ".", "join", "(", "files", ...
raise a DatacatsError if the datadir or volumes are missing or damaged
[ "raise", "a", "DatacatsError", "if", "the", "datadir", "or", "volumes", "are", "missing", "or", "damaged" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L189-L204
train
datacats/datacats
datacats/environment.py
Environment.create_directories
def create_directories(self, create_project_dir=True): """ Call once for new projects to create the initial project directories. """ return task.create_directories(self.datadir, self.sitedir, self.target if create_project_dir else None)
python
def create_directories(self, create_project_dir=True): """ Call once for new projects to create the initial project directories. """ return task.create_directories(self.datadir, self.sitedir, self.target if create_project_dir else None)
[ "def", "create_directories", "(", "self", ",", "create_project_dir", "=", "True", ")", ":", "return", "task", ".", "create_directories", "(", "self", ".", "datadir", ",", "self", ".", "sitedir", ",", "self", ".", "target", "if", "create_project_dir", "else", ...
Call once for new projects to create the initial project directories.
[ "Call", "once", "for", "new", "projects", "to", "create", "the", "initial", "project", "directories", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L206-L211
train
datacats/datacats
datacats/environment.py
Environment.create_virtualenv
def create_virtualenv(self): """ Populate venv from preloaded image """ return task.create_virtualenv(self.target, self.datadir, self._preload_image(), self._get_container_name)
python
def create_virtualenv(self): """ Populate venv from preloaded image """ return task.create_virtualenv(self.target, self.datadir, self._preload_image(), self._get_container_name)
[ "def", "create_virtualenv", "(", "self", ")", ":", "return", "task", ".", "create_virtualenv", "(", "self", ".", "target", ",", "self", ".", "datadir", ",", "self", ".", "_preload_image", "(", ")", ",", "self", ".", "_get_container_name", ")" ]
Populate venv from preloaded image
[ "Populate", "venv", "from", "preloaded", "image" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L228-L233
train
datacats/datacats
datacats/environment.py
Environment.clean_virtualenv
def clean_virtualenv(self): """ Empty our virtualenv so that new (or older) dependencies may be installed """ self.user_run_script( script=scripts.get_script_path('clean_virtualenv.sh'), args=[], rw_venv=True, )
python
def clean_virtualenv(self): """ Empty our virtualenv so that new (or older) dependencies may be installed """ self.user_run_script( script=scripts.get_script_path('clean_virtualenv.sh'), args=[], rw_venv=True, )
[ "def", "clean_virtualenv", "(", "self", ")", ":", "self", ".", "user_run_script", "(", "script", "=", "scripts", ".", "get_script_path", "(", "'clean_virtualenv.sh'", ")", ",", "args", "=", "[", "]", ",", "rw_venv", "=", "True", ",", ")" ]
Empty our virtualenv so that new (or older) dependencies may be installed
[ "Empty", "our", "virtualenv", "so", "that", "new", "(", "or", "older", ")", "dependencies", "may", "be", "installed" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L235-L244
train
datacats/datacats
datacats/environment.py
Environment.create_source
def create_source(self, datapusher=True): """ Populate ckan directory from preloaded image and copy who.ini and schema.xml info conf directory """ task.create_source(self.target, self._preload_image(), datapusher)
python
def create_source(self, datapusher=True): """ Populate ckan directory from preloaded image and copy who.ini and schema.xml info conf directory """ task.create_source(self.target, self._preload_image(), datapusher)
[ "def", "create_source", "(", "self", ",", "datapusher", "=", "True", ")", ":", "task", ".", "create_source", "(", "self", ".", "target", ",", "self", ".", "_preload_image", "(", ")", ",", "datapusher", ")" ]
Populate ckan directory from preloaded image and copy who.ini and schema.xml info conf directory
[ "Populate", "ckan", "directory", "from", "preloaded", "image", "and", "copy", "who", ".", "ini", "and", "schema", ".", "xml", "info", "conf", "directory" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L253-L258
train
datacats/datacats
datacats/environment.py
Environment.start_supporting_containers
def start_supporting_containers(self, log_syslog=False): """ Start all supporting containers (containers required for CKAN to operate) if they aren't already running. :param log_syslog: A flag to redirect all container logs to host's syslog """ log_syslog = True if ...
python
def start_supporting_containers(self, log_syslog=False): """ Start all supporting containers (containers required for CKAN to operate) if they aren't already running. :param log_syslog: A flag to redirect all container logs to host's syslog """ log_syslog = True if ...
[ "def", "start_supporting_containers", "(", "self", ",", "log_syslog", "=", "False", ")", ":", "log_syslog", "=", "True", "if", "self", ".", "always_prod", "else", "log_syslog", "# in production we always use log_syslog driver (to aggregate all the logs)", "task", ".", "st...
Start all supporting containers (containers required for CKAN to operate) if they aren't already running. :param log_syslog: A flag to redirect all container logs to host's syslog
[ "Start", "all", "supporting", "containers", "(", "containers", "required", "for", "CKAN", "to", "operate", ")", "if", "they", "aren", "t", "already", "running", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L260-L277
train
datacats/datacats
datacats/environment.py
Environment.create_ckan_ini
def create_ckan_ini(self): """ Use make-config to generate an initial development.ini file """ self.run_command( command='/scripts/run_as_user.sh /usr/lib/ckan/bin/paster make-config' ' ckan /project/development.ini', rw_project=True, ro={s...
python
def create_ckan_ini(self): """ Use make-config to generate an initial development.ini file """ self.run_command( command='/scripts/run_as_user.sh /usr/lib/ckan/bin/paster make-config' ' ckan /project/development.ini', rw_project=True, ro={s...
[ "def", "create_ckan_ini", "(", "self", ")", ":", "self", ".", "run_command", "(", "command", "=", "'/scripts/run_as_user.sh /usr/lib/ckan/bin/paster make-config'", "' ckan /project/development.ini'", ",", "rw_project", "=", "True", ",", "ro", "=", "{", "scripts", ".", ...
Use make-config to generate an initial development.ini file
[ "Use", "make", "-", "config", "to", "generate", "an", "initial", "development", ".", "ini", "file" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L295-L304
train
datacats/datacats
datacats/environment.py
Environment.update_ckan_ini
def update_ckan_ini(self, skin=True): """ Use config-tool to update development.ini with our environment settings :param skin: use environment template skin plugin True/False """ command = [ '/usr/lib/ckan/bin/paster', '--plugin=ckan', 'config-tool', '/pr...
python
def update_ckan_ini(self, skin=True): """ Use config-tool to update development.ini with our environment settings :param skin: use environment template skin plugin True/False """ command = [ '/usr/lib/ckan/bin/paster', '--plugin=ckan', 'config-tool', '/pr...
[ "def", "update_ckan_ini", "(", "self", ",", "skin", "=", "True", ")", ":", "command", "=", "[", "'/usr/lib/ckan/bin/paster'", ",", "'--plugin=ckan'", ",", "'config-tool'", ",", "'/project/development.ini'", ",", "'-e'", ",", "'sqlalchemy.url = postgresql://<hidden>'", ...
Use config-tool to update development.ini with our environment settings :param skin: use environment template skin plugin True/False
[ "Use", "config", "-", "tool", "to", "update", "development", ".", "ini", "with", "our", "environment", "settings" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L306-L329
train
datacats/datacats
datacats/environment.py
Environment.create_install_template_skin
def create_install_template_skin(self): """ Create an example ckan extension for this environment and install it """ ckan_extension_template(self.name, self.target) self.install_package_develop('ckanext-' + self.name + 'theme')
python
def create_install_template_skin(self): """ Create an example ckan extension for this environment and install it """ ckan_extension_template(self.name, self.target) self.install_package_develop('ckanext-' + self.name + 'theme')
[ "def", "create_install_template_skin", "(", "self", ")", ":", "ckan_extension_template", "(", "self", ".", "name", ",", "self", ".", "target", ")", "self", ".", "install_package_develop", "(", "'ckanext-'", "+", "self", ".", "name", "+", "'theme'", ")" ]
Create an example ckan extension for this environment and install it
[ "Create", "an", "example", "ckan", "extension", "for", "this", "environment", "and", "install", "it" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L331-L336
train
datacats/datacats
datacats/environment.py
Environment.ckan_db_init
def ckan_db_init(self, retry_seconds=DB_INIT_RETRY_SECONDS): """ Run db init to create all ckan tables :param retry_seconds: how long to retry waiting for db to start """ # XXX workaround for not knowing how long we need to wait # for postgres to be ready. fix this by ch...
python
def ckan_db_init(self, retry_seconds=DB_INIT_RETRY_SECONDS): """ Run db init to create all ckan tables :param retry_seconds: how long to retry waiting for db to start """ # XXX workaround for not knowing how long we need to wait # for postgres to be ready. fix this by ch...
[ "def", "ckan_db_init", "(", "self", ",", "retry_seconds", "=", "DB_INIT_RETRY_SECONDS", ")", ":", "# XXX workaround for not knowing how long we need to wait", "# for postgres to be ready. fix this by changing the postgres", "# entrypoint, or possibly running once with command=/bin/true", "...
Run db init to create all ckan tables :param retry_seconds: how long to retry waiting for db to start
[ "Run", "db", "init", "to", "create", "all", "ckan", "tables" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L338-L360
train
datacats/datacats
datacats/environment.py
Environment.start_ckan
def start_ckan(self, production=False, log_syslog=False, paster_reload=True, interactive=False): """ Start the apache server or paster serve :param log_syslog: A flag to redirect all container logs to host's syslog :param production: True for apache, False for paster ...
python
def start_ckan(self, production=False, log_syslog=False, paster_reload=True, interactive=False): """ Start the apache server or paster serve :param log_syslog: A flag to redirect all container logs to host's syslog :param production: True for apache, False for paster ...
[ "def", "start_ckan", "(", "self", ",", "production", "=", "False", ",", "log_syslog", "=", "False", ",", "paster_reload", "=", "True", ",", "interactive", "=", "False", ")", ":", "self", ".", "stop_ckan", "(", ")", "address", "=", "self", ".", "address",...
Start the apache server or paster serve :param log_syslog: A flag to redirect all container logs to host's syslog :param production: True for apache, False for paster serve + debug on :param paster_reload: Instruct paster to watch for file changes
[ "Start", "the", "apache", "server", "or", "paster", "serve" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L391-L450
train
datacats/datacats
datacats/environment.py
Environment._create_run_ini
def _create_run_ini(self, port, production, output='development.ini', source='development.ini', override_site_url=True): """ Create run/development.ini in datadir with debug and site_url overridden and with correct db passwords inserted """ cp = SafeConfig...
python
def _create_run_ini(self, port, production, output='development.ini', source='development.ini', override_site_url=True): """ Create run/development.ini in datadir with debug and site_url overridden and with correct db passwords inserted """ cp = SafeConfig...
[ "def", "_create_run_ini", "(", "self", ",", "port", ",", "production", ",", "output", "=", "'development.ini'", ",", "source", "=", "'development.ini'", ",", "override_site_url", "=", "True", ")", ":", "cp", "=", "SafeConfigParser", "(", ")", "try", ":", "cp...
Create run/development.ini in datadir with debug and site_url overridden and with correct db passwords inserted
[ "Create", "run", "/", "development", ".", "ini", "in", "datadir", "with", "debug", "and", "site_url", "overridden", "and", "with", "correct", "db", "passwords", "inserted" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L452-L494
train
datacats/datacats
datacats/environment.py
Environment._run_web_container
def _run_web_container(self, port, command, address, log_syslog=False, datapusher=True, interactive=False): """ Start web container on port with command """ if is_boot2docker(): ro = {} volumes_from = self._get_container_name('venv') ...
python
def _run_web_container(self, port, command, address, log_syslog=False, datapusher=True, interactive=False): """ Start web container on port with command """ if is_boot2docker(): ro = {} volumes_from = self._get_container_name('venv') ...
[ "def", "_run_web_container", "(", "self", ",", "port", ",", "command", ",", "address", ",", "log_syslog", "=", "False", ",", "datapusher", "=", "True", ",", "interactive", "=", "False", ")", ":", "if", "is_boot2docker", "(", ")", ":", "ro", "=", "{", "...
Start web container on port with command
[ "Start", "web", "container", "on", "port", "with", "command" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L496-L566
train
datacats/datacats
datacats/environment.py
Environment.wait_for_web_available
def wait_for_web_available(self): """ Wait for the web server to become available or raise DatacatsError if it fails to start. """ try: if not wait_for_service_available( self._get_container_name('web'), self.web_address(), ...
python
def wait_for_web_available(self): """ Wait for the web server to become available or raise DatacatsError if it fails to start. """ try: if not wait_for_service_available( self._get_container_name('web'), self.web_address(), ...
[ "def", "wait_for_web_available", "(", "self", ")", ":", "try", ":", "if", "not", "wait_for_service_available", "(", "self", ".", "_get_container_name", "(", "'web'", ")", ",", "self", ".", "web_address", "(", ")", ",", "WEB_START_TIMEOUT_SECONDS", ")", ":", "r...
Wait for the web server to become available or raise DatacatsError if it fails to start.
[ "Wait", "for", "the", "web", "server", "to", "become", "available", "or", "raise", "DatacatsError", "if", "it", "fails", "to", "start", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L568-L583
train
datacats/datacats
datacats/environment.py
Environment._choose_port
def _choose_port(self): """ Return a port number from 5000-5999 based on the environment name to be used as a default when the user hasn't selected one. """ # instead of random let's base it on the name chosen (and the site name) return 5000 + unpack('Q', ...
python
def _choose_port(self): """ Return a port number from 5000-5999 based on the environment name to be used as a default when the user hasn't selected one. """ # instead of random let's base it on the name chosen (and the site name) return 5000 + unpack('Q', ...
[ "def", "_choose_port", "(", "self", ")", ":", "# instead of random let's base it on the name chosen (and the site name)", "return", "5000", "+", "unpack", "(", "'Q'", ",", "sha", "(", "(", "self", ".", "name", "+", "self", ".", "site_name", ")", ".", "decode", "...
Return a port number from 5000-5999 based on the environment name to be used as a default when the user hasn't selected one.
[ "Return", "a", "port", "number", "from", "5000", "-", "5999", "based", "on", "the", "environment", "name", "to", "be", "used", "as", "a", "default", "when", "the", "user", "hasn", "t", "selected", "one", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L585-L593
train
datacats/datacats
datacats/environment.py
Environment._next_port
def _next_port(self, port): """ Return another port from the 5000-5999 range """ port = 5000 + (port + 1) % 1000 if port == self.port: raise DatacatsError('Too many instances running') return port
python
def _next_port(self, port): """ Return another port from the 5000-5999 range """ port = 5000 + (port + 1) % 1000 if port == self.port: raise DatacatsError('Too many instances running') return port
[ "def", "_next_port", "(", "self", ",", "port", ")", ":", "port", "=", "5000", "+", "(", "port", "+", "1", ")", "%", "1000", "if", "port", "==", "self", ".", "port", ":", "raise", "DatacatsError", "(", "'Too many instances running'", ")", "return", "por...
Return another port from the 5000-5999 range
[ "Return", "another", "port", "from", "the", "5000", "-", "5999", "range" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L595-L602
train
datacats/datacats
datacats/environment.py
Environment.stop_ckan
def stop_ckan(self): """ Stop and remove the web container """ remove_container(self._get_container_name('web'), force=True) remove_container(self._get_container_name('datapusher'), force=True)
python
def stop_ckan(self): """ Stop and remove the web container """ remove_container(self._get_container_name('web'), force=True) remove_container(self._get_container_name('datapusher'), force=True)
[ "def", "stop_ckan", "(", "self", ")", ":", "remove_container", "(", "self", ".", "_get_container_name", "(", "'web'", ")", ",", "force", "=", "True", ")", "remove_container", "(", "self", ".", "_get_container_name", "(", "'datapusher'", ")", ",", "force", "=...
Stop and remove the web container
[ "Stop", "and", "remove", "the", "web", "container" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L604-L609
train
datacats/datacats
datacats/environment.py
Environment._current_web_port
def _current_web_port(self): """ return just the port number for the web container, or None if not running """ info = inspect_container(self._get_container_name('web')) if info is None: return None try: if not info['State']['Running']: ...
python
def _current_web_port(self): """ return just the port number for the web container, or None if not running """ info = inspect_container(self._get_container_name('web')) if info is None: return None try: if not info['State']['Running']: ...
[ "def", "_current_web_port", "(", "self", ")", ":", "info", "=", "inspect_container", "(", "self", ".", "_get_container_name", "(", "'web'", ")", ")", "if", "info", "is", "None", ":", "return", "None", "try", ":", "if", "not", "info", "[", "'State'", "]",...
return just the port number for the web container, or None if not running
[ "return", "just", "the", "port", "number", "for", "the", "web", "container", "or", "None", "if", "not", "running" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L611-L624
train
datacats/datacats
datacats/environment.py
Environment.add_extra_container
def add_extra_container(self, container, error_on_exists=False): """ Add a container as a 'extra'. These are running containers which are not necessary for running default CKAN but are useful for certain extensions :param container: The container name to add :param error_on_exist...
python
def add_extra_container(self, container, error_on_exists=False): """ Add a container as a 'extra'. These are running containers which are not necessary for running default CKAN but are useful for certain extensions :param container: The container name to add :param error_on_exist...
[ "def", "add_extra_container", "(", "self", ",", "container", ",", "error_on_exists", "=", "False", ")", ":", "if", "container", "in", "self", ".", "extra_containers", ":", "if", "error_on_exists", ":", "raise", "DatacatsError", "(", "'{} is already added as an extra...
Add a container as a 'extra'. These are running containers which are not necessary for running default CKAN but are useful for certain extensions :param container: The container name to add :param error_on_exists: Raise a DatacatsError if the extra container already exists.
[ "Add", "a", "container", "as", "a", "extra", ".", "These", "are", "running", "containers", "which", "are", "not", "necessary", "for", "running", "default", "CKAN", "but", "are", "useful", "for", "certain", "extensions", ":", "param", "container", ":", "The",...
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L636-L657
train
datacats/datacats
datacats/environment.py
Environment.web_address
def web_address(self): """ Return the url of the web server or None if not running """ port = self._current_web_port() address = self.address or '127.0.0.1' if port is None: return None return 'http://{0}:{1}/'.format( address if address an...
python
def web_address(self): """ Return the url of the web server or None if not running """ port = self._current_web_port() address = self.address or '127.0.0.1' if port is None: return None return 'http://{0}:{1}/'.format( address if address an...
[ "def", "web_address", "(", "self", ")", ":", "port", "=", "self", ".", "_current_web_port", "(", ")", "address", "=", "self", ".", "address", "or", "'127.0.0.1'", "if", "port", "is", "None", ":", "return", "None", "return", "'http://{0}:{1}/'", ".", "forma...
Return the url of the web server or None if not running
[ "Return", "the", "url", "of", "the", "web", "server", "or", "None", "if", "not", "running" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L665-L675
train
datacats/datacats
datacats/environment.py
Environment.create_admin_set_password
def create_admin_set_password(self, password): """ create 'admin' account with given password """ with open(self.sitedir + '/run/admin.json', 'w') as out: json.dump({ 'name': 'admin', 'email': 'none', 'password': password, ...
python
def create_admin_set_password(self, password): """ create 'admin' account with given password """ with open(self.sitedir + '/run/admin.json', 'w') as out: json.dump({ 'name': 'admin', 'email': 'none', 'password': password, ...
[ "def", "create_admin_set_password", "(", "self", ",", "password", ")", ":", "with", "open", "(", "self", ".", "sitedir", "+", "'/run/admin.json'", ",", "'w'", ")", "as", "out", ":", "json", ".", "dump", "(", "{", "'name'", ":", "'admin'", ",", "'email'",...
create 'admin' account with given password
[ "create", "admin", "account", "with", "given", "password" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L677-L696
train
datacats/datacats
datacats/environment.py
Environment.interactive_shell
def interactive_shell(self, command=None, paster=False, detach=False): """ launch interactive shell session with all writable volumes :param: list of strings to execute instead of bash """ if not exists(self.target + '/.bash_profile'): # this file is required for act...
python
def interactive_shell(self, command=None, paster=False, detach=False): """ launch interactive shell session with all writable volumes :param: list of strings to execute instead of bash """ if not exists(self.target + '/.bash_profile'): # this file is required for act...
[ "def", "interactive_shell", "(", "self", ",", "command", "=", "None", ",", "paster", "=", "False", ",", "detach", "=", "False", ")", ":", "if", "not", "exists", "(", "self", ".", "target", "+", "'/.bash_profile'", ")", ":", "# this file is required for activ...
launch interactive shell session with all writable volumes :param: list of strings to execute instead of bash
[ "launch", "interactive", "shell", "session", "with", "all", "writable", "volumes" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L698-L768
train
datacats/datacats
datacats/environment.py
Environment.install_package_requirements
def install_package_requirements(self, psrc, stream_output=None): """ Install from requirements.txt file found in psrc :param psrc: name of directory in environment directory """ package = self.target + '/' + psrc assert isdir(package), package reqname = '/requir...
python
def install_package_requirements(self, psrc, stream_output=None): """ Install from requirements.txt file found in psrc :param psrc: name of directory in environment directory """ package = self.target + '/' + psrc assert isdir(package), package reqname = '/requir...
[ "def", "install_package_requirements", "(", "self", ",", "psrc", ",", "stream_output", "=", "None", ")", ":", "package", "=", "self", ".", "target", "+", "'/'", "+", "psrc", "assert", "isdir", "(", "package", ")", ",", "package", "reqname", "=", "'/require...
Install from requirements.txt file found in psrc :param psrc: name of directory in environment directory
[ "Install", "from", "requirements", ".", "txt", "file", "found", "in", "psrc" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L770-L789
train
datacats/datacats
datacats/environment.py
Environment.purge_data
def purge_data(self, which_sites=None, never_delete=False): """ Remove uploaded files, postgres db, solr index, venv """ # Default to the set of all sites if not exists(self.datadir + '/.version'): format_version = 1 else: with open(self.datadir + ...
python
def purge_data(self, which_sites=None, never_delete=False): """ Remove uploaded files, postgres db, solr index, venv """ # Default to the set of all sites if not exists(self.datadir + '/.version'): format_version = 1 else: with open(self.datadir + ...
[ "def", "purge_data", "(", "self", ",", "which_sites", "=", "None", ",", "never_delete", "=", "False", ")", ":", "# Default to the set of all sites", "if", "not", "exists", "(", "self", ".", "datadir", "+", "'/.version'", ")", ":", "format_version", "=", "1", ...
Remove uploaded files, postgres db, solr index, venv
[ "Remove", "uploaded", "files", "postgres", "db", "solr", "index", "venv" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L856-L925
train
datacats/datacats
datacats/environment.py
Environment.logs
def logs(self, container, tail='all', follow=False, timestamps=False): """ :param container: 'web', 'solr' or 'postgres' :param tail: number of lines to show :param follow: True to return generator instead of list :param timestamps: True to include timestamps """ ...
python
def logs(self, container, tail='all', follow=False, timestamps=False): """ :param container: 'web', 'solr' or 'postgres' :param tail: number of lines to show :param follow: True to return generator instead of list :param timestamps: True to include timestamps """ ...
[ "def", "logs", "(", "self", ",", "container", ",", "tail", "=", "'all'", ",", "follow", "=", "False", ",", "timestamps", "=", "False", ")", ":", "return", "container_logs", "(", "self", ".", "_get_container_name", "(", "container", ")", ",", "tail", ",",...
:param container: 'web', 'solr' or 'postgres' :param tail: number of lines to show :param follow: True to return generator instead of list :param timestamps: True to include timestamps
[ ":", "param", "container", ":", "web", "solr", "or", "postgres", ":", "param", "tail", ":", "number", "of", "lines", "to", "show", ":", "param", "follow", ":", "True", "to", "return", "generator", "instead", "of", "list", ":", "param", "timestamps", ":",...
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L927-L938
train
datacats/datacats
datacats/environment.py
Environment._proxy_settings
def _proxy_settings(self): """ Create/replace ~/.datacats/run/proxy-environment and return entry for ro mount for containers """ if not ('https_proxy' in environ or 'HTTPS_PROXY' in environ or 'http_proxy' in environ or 'HTTP_PROXY' in environ): return...
python
def _proxy_settings(self): """ Create/replace ~/.datacats/run/proxy-environment and return entry for ro mount for containers """ if not ('https_proxy' in environ or 'HTTPS_PROXY' in environ or 'http_proxy' in environ or 'HTTP_PROXY' in environ): return...
[ "def", "_proxy_settings", "(", "self", ")", ":", "if", "not", "(", "'https_proxy'", "in", "environ", "or", "'HTTPS_PROXY'", "in", "environ", "or", "'http_proxy'", "in", "environ", "or", "'HTTP_PROXY'", "in", "environ", ")", ":", "return", "{", "}", "https_pr...
Create/replace ~/.datacats/run/proxy-environment and return entry for ro mount for containers
[ "Create", "/", "replace", "~", "/", ".", "datacats", "/", "run", "/", "proxy", "-", "environment", "and", "return", "entry", "for", "ro", "mount", "for", "containers" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L949-L984
train
datacats/datacats
datacats/environment.py
Environment._get_container_name
def _get_container_name(self, container_type): """ Gets the full name of a container of the type specified. Currently the supported types are: - 'venv' - 'postgres' - 'solr' - 'web' - 'pgdata' - 'lessc' - 'datapu...
python
def _get_container_name(self, container_type): """ Gets the full name of a container of the type specified. Currently the supported types are: - 'venv' - 'postgres' - 'solr' - 'web' - 'pgdata' - 'lessc' - 'datapu...
[ "def", "_get_container_name", "(", "self", ",", "container_type", ")", ":", "if", "container_type", "in", "[", "'venv'", "]", ":", "return", "'datacats_{}_{}'", ".", "format", "(", "container_type", ",", "self", ".", "name", ")", "else", ":", "return", "'dat...
Gets the full name of a container of the type specified. Currently the supported types are: - 'venv' - 'postgres' - 'solr' - 'web' - 'pgdata' - 'lessc' - 'datapusher' - 'redis' The name will be formatted appr...
[ "Gets", "the", "full", "name", "of", "a", "container", "of", "the", "type", "specified", ".", "Currently", "the", "supported", "types", "are", ":", "-", "venv", "-", "postgres", "-", "solr", "-", "web", "-", "pgdata", "-", "lessc", "-", "datapusher", "...
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L986-L1006
train
datacats/datacats
datacats/cli/less.py
less
def less(environment, opts): # pylint: disable=unused-argument """Recompiles less files in an environment. Usage: datacats less [ENVIRONMENT] ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.' """ require_extra_image(LESSC_IMAGE) print 'Converting .less files...
python
def less(environment, opts): # pylint: disable=unused-argument """Recompiles less files in an environment. Usage: datacats less [ENVIRONMENT] ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.' """ require_extra_image(LESSC_IMAGE) print 'Converting .less files...
[ "def", "less", "(", "environment", ",", "opts", ")", ":", "# pylint: disable=unused-argument", "require_extra_image", "(", "LESSC_IMAGE", ")", "print", "'Converting .less files to .css...'", "for", "log", "in", "environment", ".", "compile_less", "(", ")", ":", "print...
Recompiles less files in an environment. Usage: datacats less [ENVIRONMENT] ENVIRONMENT may be an environment name or a path to an environment directory. Default: '.'
[ "Recompiles", "less", "files", "in", "an", "environment", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/less.py#L13-L27
train
Britefury/batchup
batchup/datasets/dataset.py
fetch_and_convert_dataset
def fetch_and_convert_dataset(source_files, target_filename): """ Decorator applied to a dataset conversion function that converts acquired source files into a dataset file that BatchUp can use. Parameters ---------- source_file: list of `AbstractSourceFile` instances A list of files to...
python
def fetch_and_convert_dataset(source_files, target_filename): """ Decorator applied to a dataset conversion function that converts acquired source files into a dataset file that BatchUp can use. Parameters ---------- source_file: list of `AbstractSourceFile` instances A list of files to...
[ "def", "fetch_and_convert_dataset", "(", "source_files", ",", "target_filename", ")", ":", "if", "not", "isinstance", "(", "target_filename", ",", "six", ".", "string_types", ")", "and", "not", "callable", "(", "target_filename", ")", ":", "raise", "TypeError", ...
Decorator applied to a dataset conversion function that converts acquired source files into a dataset file that BatchUp can use. Parameters ---------- source_file: list of `AbstractSourceFile` instances A list of files to be acquired target_filename: str or callable The name of the ...
[ "Decorator", "applied", "to", "a", "dataset", "conversion", "function", "that", "converts", "acquired", "source", "files", "into", "a", "dataset", "file", "that", "BatchUp", "can", "use", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L252-L399
train
Britefury/batchup
batchup/datasets/dataset.py
delete_dataset_cache
def delete_dataset_cache(*filenames): """ Delete the cache (converted files) for a dataset. Parameters ---------- filenames: str Filenames of files to delete """ for filename in filenames: filename = path_string(filename) path = config.get_data_path(filename) ...
python
def delete_dataset_cache(*filenames): """ Delete the cache (converted files) for a dataset. Parameters ---------- filenames: str Filenames of files to delete """ for filename in filenames: filename = path_string(filename) path = config.get_data_path(filename) ...
[ "def", "delete_dataset_cache", "(", "*", "filenames", ")", ":", "for", "filename", "in", "filenames", ":", "filename", "=", "path_string", "(", "filename", ")", "path", "=", "config", ".", "get_data_path", "(", "filename", ")", "if", "os", ".", "path", "."...
Delete the cache (converted files) for a dataset. Parameters ---------- filenames: str Filenames of files to delete
[ "Delete", "the", "cache", "(", "converted", "files", ")", "for", "a", "dataset", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L402-L415
train
Britefury/batchup
batchup/datasets/dataset.py
DownloadSourceFile.acquire
def acquire(self, **kwargs): """ Download the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the download failed. """ return config.download_data(self.temp_filename, se...
python
def acquire(self, **kwargs): """ Download the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the download failed. """ return config.download_data(self.temp_filename, se...
[ "def", "acquire", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "config", ".", "download_data", "(", "self", ".", "temp_filename", ",", "self", ".", "url", ",", "self", ".", "sha256", ")" ]
Download the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the download failed.
[ "Download", "the", "file", "and", "return", "its", "path" ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L124-L135
train
Britefury/batchup
batchup/datasets/dataset.py
CopySourceFile.acquire
def acquire(self, **kwargs): """ Copy the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the copy failed. """ if self.source_path is None: source_path = kwa...
python
def acquire(self, **kwargs): """ Copy the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the copy failed. """ if self.source_path is None: source_path = kwa...
[ "def", "acquire", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "source_path", "is", "None", ":", "source_path", "=", "kwargs", "[", "self", ".", "arg_name", "]", "else", ":", "source_path", "=", "self", ".", "source_path", "return...
Copy the file and return its path Returns ------- str or None The path of the file in BatchUp's temporary directory or None if the copy failed.
[ "Copy", "the", "file", "and", "return", "its", "path" ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L185-L199
train
Britefury/batchup
batchup/datasets/dataset.py
ExistingSourceFile.acquire
def acquire(self, **kwargs): """ Copy the file and return its path Returns ------- str or None The path of the file or None if it does not exist or if verification failed. """ path = path_string(self.path) if os.path.exists(path): ...
python
def acquire(self, **kwargs): """ Copy the file and return its path Returns ------- str or None The path of the file or None if it does not exist or if verification failed. """ path = path_string(self.path) if os.path.exists(path): ...
[ "def", "acquire", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "path_string", "(", "self", ".", "path", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "if", "config", ".", "verify_file", "(", "path", ",", "sel...
Copy the file and return its path Returns ------- str or None The path of the file or None if it does not exist or if verification failed.
[ "Copy", "the", "file", "and", "return", "its", "path" ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/datasets/dataset.py#L235-L249
train
datacats/datacats
datacats/cli/pull.py
_retry_func
def _retry_func(func, param, num, retry_notif, error_msg): """ A function which retries a given function num times and calls retry_notif each time the function is retried. :param func: The function to retry num times. :param num: The number of times to try before giving up. :param retry_notif: W...
python
def _retry_func(func, param, num, retry_notif, error_msg): """ A function which retries a given function num times and calls retry_notif each time the function is retried. :param func: The function to retry num times. :param num: The number of times to try before giving up. :param retry_notif: W...
[ "def", "_retry_func", "(", "func", ",", "param", ",", "num", ",", "retry_notif", ",", "error_msg", ")", ":", "for", "retry_num", "in", "range", "(", "num", ")", ":", "if", "retry_num", ":", "retry_notif", "(", "param", ",", "retry_num", ")", "try", ":"...
A function which retries a given function num times and calls retry_notif each time the function is retried. :param func: The function to retry num times. :param num: The number of times to try before giving up. :param retry_notif: Will be called with the same parameter as func if we have to retry the ...
[ "A", "function", "which", "retries", "a", "given", "function", "num", "times", "and", "calls", "retry_notif", "each", "time", "the", "function", "is", "retried", ".", ":", "param", "func", ":", "The", "function", "to", "retry", "num", "times", ".", ":", ...
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/pull.py#L55-L77
train
Britefury/batchup
batchup/work_pool.py
WorkStream.retrieve
def retrieve(self): """ Retrieve a result from executing a task. Note that tasks are executed in order and that if the next task has not yet completed, this call will block until the result is available. Returns ------- A result from the result buffer. ""...
python
def retrieve(self): """ Retrieve a result from executing a task. Note that tasks are executed in order and that if the next task has not yet completed, this call will block until the result is available. Returns ------- A result from the result buffer. ""...
[ "def", "retrieve", "(", "self", ")", ":", "if", "len", "(", "self", ".", "__result_buffer", ")", ">", "0", ":", "res", "=", "self", ".", "__result_buffer", ".", "popleft", "(", ")", "value", "=", "res", ".", "get", "(", ")", "else", ":", "return", ...
Retrieve a result from executing a task. Note that tasks are executed in order and that if the next task has not yet completed, this call will block until the result is available. Returns ------- A result from the result buffer.
[ "Retrieve", "a", "result", "from", "executing", "a", "task", ".", "Note", "that", "tasks", "are", "executed", "in", "order", "and", "that", "if", "the", "next", "task", "has", "not", "yet", "completed", "this", "call", "will", "block", "until", "the", "r...
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/work_pool.py#L407-L425
train
datacats/datacats
datacats/cli/install.py
install
def install(environment, opts): """Install or reinstall Python packages within this environment Usage: datacats install [-q] [--address=IP] [ENVIRONMENT [PACKAGE ...]] datacats install -c [q] [--address=IP] [ENVIRONMENT] Options: --address=IP The address to bind to when reloading after install -c...
python
def install(environment, opts): """Install or reinstall Python packages within this environment Usage: datacats install [-q] [--address=IP] [ENVIRONMENT [PACKAGE ...]] datacats install -c [q] [--address=IP] [ENVIRONMENT] Options: --address=IP The address to bind to when reloading after install -c...
[ "def", "install", "(", "environment", ",", "opts", ")", ":", "environment", ".", "require_data", "(", ")", "install_all", "(", "environment", ",", "opts", "[", "'--clean'", "]", ",", "verbose", "=", "not", "opts", "[", "'--quiet'", "]", ",", "packages", ...
Install or reinstall Python packages within this environment Usage: datacats install [-q] [--address=IP] [ENVIRONMENT [PACKAGE ...]] datacats install -c [q] [--address=IP] [ENVIRONMENT] Options: --address=IP The address to bind to when reloading after install -c --clean Reinstall packages ...
[ "Install", "or", "reinstall", "Python", "packages", "within", "this", "environment" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/install.py#L20-L52
train
datacats/datacats
datacats/cli/migrate.py
migrate
def migrate(opts): """Migrate an environment to a given revision of the datadir format. Usage: datacats migrate [-y] [-r VERSION] [ENVIRONMENT_DIR] Options: -r --revision=VERSION The version of the datadir format you want to convert to [default: 2] -y --yes Answer yes...
python
def migrate(opts): """Migrate an environment to a given revision of the datadir format. Usage: datacats migrate [-y] [-r VERSION] [ENVIRONMENT_DIR] Options: -r --revision=VERSION The version of the datadir format you want to convert to [default: 2] -y --yes Answer yes...
[ "def", "migrate", "(", "opts", ")", ":", "try", ":", "version", "=", "int", "(", "opts", "[", "'--revision'", "]", ")", "except", ":", "raise", "DatacatsError", "(", "'--revision parameter must be an integer.'", ")", "always_yes", "=", "opts", "[", "'--yes'", ...
Migrate an environment to a given revision of the datadir format. Usage: datacats migrate [-y] [-r VERSION] [ENVIRONMENT_DIR] Options: -r --revision=VERSION The version of the datadir format you want to convert to [default: 2] -y --yes Answer yes to all questions. Defaul...
[ "Migrate", "an", "environment", "to", "a", "given", "revision", "of", "the", "datadir", "format", "." ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/migrate.py#L8-L38
train
datacats/datacats
datacats/cli/deploy.py
deploy
def deploy(environment, opts, profile): """Deploy environment to production DataCats.com cloud service Usage: datacats deploy [--create] [ENVIRONMENT [TARGET_NAME]] Options: --create Create a new environment on DataCats.com instead of updating an existing environment ...
python
def deploy(environment, opts, profile): """Deploy environment to production DataCats.com cloud service Usage: datacats deploy [--create] [ENVIRONMENT [TARGET_NAME]] Options: --create Create a new environment on DataCats.com instead of updating an existing environment ...
[ "def", "deploy", "(", "environment", ",", "opts", ",", "profile", ")", ":", "target_name", "=", "opts", "[", "'TARGET_NAME'", "]", "if", "target_name", "is", "None", ":", "target_name", "=", "environment", ".", "name", "if", "not", "valid_deploy_name", "(", ...
Deploy environment to production DataCats.com cloud service Usage: datacats deploy [--create] [ENVIRONMENT [TARGET_NAME]] Options: --create Create a new environment on DataCats.com instead of updating an existing environment ENVIRONMENT may be an environment name or a pat...
[ "Deploy", "environment", "to", "production", "DataCats", ".", "com", "cloud", "service" ]
e4bae503efa997660fb3f34fe166699569653157
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/deploy.py#L14-L53
train
Britefury/batchup
batchup/data_source.py
_trim_batch
def _trim_batch(batch, length): """Trim the mini-batch `batch` to the size `length`. `batch` can be: - a NumPy array, in which case it's first axis will be trimmed to size `length` - a tuple, in which case `_trim_batch` applied recursively to each element and the resulting tuple returned ...
python
def _trim_batch(batch, length): """Trim the mini-batch `batch` to the size `length`. `batch` can be: - a NumPy array, in which case it's first axis will be trimmed to size `length` - a tuple, in which case `_trim_batch` applied recursively to each element and the resulting tuple returned ...
[ "def", "_trim_batch", "(", "batch", ",", "length", ")", ":", "if", "isinstance", "(", "batch", ",", "tuple", ")", ":", "return", "tuple", "(", "[", "_trim_batch", "(", "b", ",", "length", ")", "for", "b", "in", "batch", "]", ")", "else", ":", "retu...
Trim the mini-batch `batch` to the size `length`. `batch` can be: - a NumPy array, in which case it's first axis will be trimmed to size `length` - a tuple, in which case `_trim_batch` applied recursively to each element and the resulting tuple returned As a consequence, mini-batches can b...
[ "Trim", "the", "mini", "-", "batch", "batch", "to", "the", "size", "length", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L41-L68
train
Britefury/batchup
batchup/data_source.py
batch_map_concat
def batch_map_concat(func, batch_iter, progress_iter_func=None, n_batches=None, prepend_args=None): """ Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the per-sample results. The function `func` should return the result ...
python
def batch_map_concat(func, batch_iter, progress_iter_func=None, n_batches=None, prepend_args=None): """ Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the per-sample results. The function `func` should return the result ...
[ "def", "batch_map_concat", "(", "func", ",", "batch_iter", ",", "progress_iter_func", "=", "None", ",", "n_batches", "=", "None", ",", "prepend_args", "=", "None", ")", ":", "# Accumulator for results and number of samples", "results", "=", "[", "]", "# If `progress...
Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the per-sample results. The function `func` should return the result for each sample in the mini-batch as an array. To return multiple results (e.g. loss and errors) return a tuple of arrays (e....
[ "Apply", "a", "function", "to", "all", "the", "samples", "that", "are", "accessed", "as", "mini", "-", "batches", "obtained", "from", "an", "iterator", ".", "Returns", "the", "per", "-", "sample", "results", "." ]
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1478-L1599
train
Britefury/batchup
batchup/data_source.py
batch_map_mean
def batch_map_mean(func, batch_iter, progress_iter_func=None, sum_axis=None, n_batches=None, prepend_args=None): """ Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the across-samples mean of the results returned by `func` ...
python
def batch_map_mean(func, batch_iter, progress_iter_func=None, sum_axis=None, n_batches=None, prepend_args=None): """ Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the across-samples mean of the results returned by `func` ...
[ "def", "batch_map_mean", "(", "func", ",", "batch_iter", ",", "progress_iter_func", "=", "None", ",", "sum_axis", "=", "None", ",", "n_batches", "=", "None", ",", "prepend_args", "=", "None", ")", ":", "# Accumulator for results and number of samples", "results_accu...
Apply a function to all the samples that are accessed as mini-batches obtained from an iterator. Returns the across-samples mean of the results returned by `func` The `sum_axis` arguments tells `mean_batch_map` how to process the results of `func` before accumulating them: - If `sum_axis` is `None`...
[ "Apply", "a", "function", "to", "all", "the", "samples", "that", "are", "accessed", "as", "mini", "-", "batches", "obtained", "from", "an", "iterator", ".", "Returns", "the", "across", "-", "samples", "mean", "of", "the", "results", "returned", "by", "func...
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1602-L1779
train
Britefury/batchup
batchup/data_source.py
coerce_data_source
def coerce_data_source(x): """ Helper function to coerce an object into a data source, selecting the appropriate data source class for the given object. If `x` is already a data source it is returned as is. Parameters ---------- x: any The object to coerce. If `x` is a data source, ...
python
def coerce_data_source(x): """ Helper function to coerce an object into a data source, selecting the appropriate data source class for the given object. If `x` is already a data source it is returned as is. Parameters ---------- x: any The object to coerce. If `x` is a data source, ...
[ "def", "coerce_data_source", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "AbstractDataSource", ")", ":", "return", "x", "elif", "isinstance", "(", "x", ",", "(", "list", ",", "tuple", ")", ")", ":", "# Sequence of array-likes", "items", "=", "...
Helper function to coerce an object into a data source, selecting the appropriate data source class for the given object. If `x` is already a data source it is returned as is. Parameters ---------- x: any The object to coerce. If `x` is a data source, it is returned as is. If it is ...
[ "Helper", "function", "to", "coerce", "an", "object", "into", "a", "data", "source", "selecting", "the", "appropriate", "data", "source", "class", "for", "the", "given", "object", ".", "If", "x", "is", "already", "a", "data", "source", "it", "is", "returne...
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L1800-L1849
train
Britefury/batchup
batchup/data_source.py
AbstractDataSource.batch_map_concat
def batch_map_concat(self, func, batch_size, progress_iter_func=None, n_batches=None, prepend_args=None, **kwargs): """A batch oriented implementation of `map`. Applies a function to all the samples in this data source by breaking the data into mini-batches and applying ...
python
def batch_map_concat(self, func, batch_size, progress_iter_func=None, n_batches=None, prepend_args=None, **kwargs): """A batch oriented implementation of `map`. Applies a function to all the samples in this data source by breaking the data into mini-batches and applying ...
[ "def", "batch_map_concat", "(", "self", ",", "func", ",", "batch_size", ",", "progress_iter_func", "=", "None", ",", "n_batches", "=", "None", ",", "prepend_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "n_batches", "is", "None", ":", "n",...
A batch oriented implementation of `map`. Applies a function to all the samples in this data source by breaking the data into mini-batches and applying the function to each mini-batch. Returns the per-sample results. This method is a wrapper around the :func:`batch_map` function...
[ "A", "batch", "oriented", "implementation", "of", "map", ".", "Applies", "a", "function", "to", "all", "the", "samples", "in", "this", "data", "source", "by", "breaking", "the", "data", "into", "mini", "-", "batches", "and", "applying", "the", "function", ...
3fc2304e629f813c05f9e7a85a18acef3581a536
https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/data_source.py#L123-L188
train