repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
spotify/luigi
luigi/contrib/gcs.py
_wait_for_consistency
def _wait_for_consistency(checker): """Eventual consistency: wait until GCS reports something is true. This is necessary for e.g. create/delete where the operation might return, but won't be reflected for a bit. """ for _ in xrange(EVENTUAL_CONSISTENCY_MAX_SLEEPS): if checker(): ...
python
def _wait_for_consistency(checker): """Eventual consistency: wait until GCS reports something is true. This is necessary for e.g. create/delete where the operation might return, but won't be reflected for a bit. """ for _ in xrange(EVENTUAL_CONSISTENCY_MAX_SLEEPS): if checker(): ...
[ "def", "_wait_for_consistency", "(", "checker", ")", ":", "for", "_", "in", "xrange", "(", "EVENTUAL_CONSISTENCY_MAX_SLEEPS", ")", ":", "if", "checker", "(", ")", ":", "return", "time", ".", "sleep", "(", "EVENTUAL_CONSISTENCY_SLEEP_INTERVAL", ")", "logger", "."...
Eventual consistency: wait until GCS reports something is true. This is necessary for e.g. create/delete where the operation might return, but won't be reflected for a bit.
[ "Eventual", "consistency", ":", "wait", "until", "GCS", "reports", "something", "is", "true", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/gcs.py#L68-L81
train
spotify/luigi
luigi/contrib/gcs.py
GCSClient.move
def move(self, source_path, destination_path): """ Rename/move an object from one GCS location to another. """ self.copy(source_path, destination_path) self.remove(source_path)
python
def move(self, source_path, destination_path): """ Rename/move an object from one GCS location to another. """ self.copy(source_path, destination_path) self.remove(source_path)
[ "def", "move", "(", "self", ",", "source_path", ",", "destination_path", ")", ":", "self", ".", "copy", "(", "source_path", ",", "destination_path", ")", "self", ".", "remove", "(", "source_path", ")" ]
Rename/move an object from one GCS location to another.
[ "Rename", "/", "move", "an", "object", "from", "one", "GCS", "location", "to", "another", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/gcs.py#L344-L349
train
spotify/luigi
luigi/contrib/gcs.py
GCSClient.listdir
def listdir(self, path): """ Get an iterable with GCS folder contents. Iterable contains paths relative to queried path. """ bucket, obj = self._path_to_bucket_and_key(path) obj_prefix = self._add_path_delimiter(obj) if self._is_root(obj_prefix): obj_...
python
def listdir(self, path): """ Get an iterable with GCS folder contents. Iterable contains paths relative to queried path. """ bucket, obj = self._path_to_bucket_and_key(path) obj_prefix = self._add_path_delimiter(obj) if self._is_root(obj_prefix): obj_...
[ "def", "listdir", "(", "self", ",", "path", ")", ":", "bucket", ",", "obj", "=", "self", ".", "_path_to_bucket_and_key", "(", "path", ")", "obj_prefix", "=", "self", ".", "_add_path_delimiter", "(", "obj", ")", "if", "self", ".", "_is_root", "(", "obj_pr...
Get an iterable with GCS folder contents. Iterable contains paths relative to queried path.
[ "Get", "an", "iterable", "with", "GCS", "folder", "contents", ".", "Iterable", "contains", "paths", "relative", "to", "queried", "path", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/gcs.py#L351-L364
train
spotify/luigi
luigi/contrib/gcs.py
GCSClient.list_wildcard
def list_wildcard(self, wildcard_path): """Yields full object URIs matching the given wildcard. Currently only the '*' wildcard after the last path delimiter is supported. (If we need "full" wildcard functionality we should bring in gsutil dependency with its https://github.com/GoogleC...
python
def list_wildcard(self, wildcard_path): """Yields full object URIs matching the given wildcard. Currently only the '*' wildcard after the last path delimiter is supported. (If we need "full" wildcard functionality we should bring in gsutil dependency with its https://github.com/GoogleC...
[ "def", "list_wildcard", "(", "self", ",", "wildcard_path", ")", ":", "path", ",", "wildcard_obj", "=", "wildcard_path", ".", "rsplit", "(", "'/'", ",", "1", ")", "assert", "'*'", "not", "in", "path", ",", "\"The '*' wildcard character is only supported after the l...
Yields full object URIs matching the given wildcard. Currently only the '*' wildcard after the last path delimiter is supported. (If we need "full" wildcard functionality we should bring in gsutil dependency with its https://github.com/GoogleCloudPlatform/gsutil/blob/master/gslib/wildcard_iter...
[ "Yields", "full", "object", "URIs", "matching", "the", "given", "wildcard", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/gcs.py#L366-L382
train
spotify/luigi
luigi/contrib/gcs.py
GCSClient.download
def download(self, path, chunksize=None, chunk_callback=lambda _: False): """Downloads the object contents to local file system. Optionally stops after the first chunk for which chunk_callback returns True. """ chunksize = chunksize or self.chunksize bucket, obj = self._path_to_...
python
def download(self, path, chunksize=None, chunk_callback=lambda _: False): """Downloads the object contents to local file system. Optionally stops after the first chunk for which chunk_callback returns True. """ chunksize = chunksize or self.chunksize bucket, obj = self._path_to_...
[ "def", "download", "(", "self", ",", "path", ",", "chunksize", "=", "None", ",", "chunk_callback", "=", "lambda", "_", ":", "False", ")", ":", "chunksize", "=", "chunksize", "or", "self", ".", "chunksize", "bucket", ",", "obj", "=", "self", ".", "_path...
Downloads the object contents to local file system. Optionally stops after the first chunk for which chunk_callback returns True.
[ "Downloads", "the", "object", "contents", "to", "local", "file", "system", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/gcs.py#L384-L428
train
spotify/luigi
luigi/format.py
InputPipeProcessWrapper.create_subprocess
def create_subprocess(self, command): """ http://www.chiark.greenend.org.uk/ucgi/~cjwatson/blosxom/2009-07-02-python-sigpipe.html """ def subprocess_setup(): # Python installs a SIGPIPE handler by default. This is usually not what # non-Python subprocesses expect...
python
def create_subprocess(self, command): """ http://www.chiark.greenend.org.uk/ucgi/~cjwatson/blosxom/2009-07-02-python-sigpipe.html """ def subprocess_setup(): # Python installs a SIGPIPE handler by default. This is usually not what # non-Python subprocesses expect...
[ "def", "create_subprocess", "(", "self", ",", "command", ")", ":", "def", "subprocess_setup", "(", ")", ":", "# Python installs a SIGPIPE handler by default. This is usually not what", "# non-Python subprocesses expect.", "signal", ".", "signal", "(", "signal", ".", "SIGPIP...
http://www.chiark.greenend.org.uk/ucgi/~cjwatson/blosxom/2009-07-02-python-sigpipe.html
[ "http", ":", "//", "www", ".", "chiark", ".", "greenend", ".", "org", ".", "uk", "/", "ucgi", "/", "~cjwatson", "/", "blosxom", "/", "2009", "-", "07", "-", "02", "-", "python", "-", "sigpipe", ".", "html" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/format.py#L93-L107
train
spotify/luigi
luigi/format.py
OutputPipeProcessWrapper._finish
def _finish(self): """ Closes and waits for subprocess to exit. """ if self._process.returncode is None: self._process.stdin.flush() self._process.stdin.close() self._process.wait() self.closed = True
python
def _finish(self): """ Closes and waits for subprocess to exit. """ if self._process.returncode is None: self._process.stdin.flush() self._process.stdin.close() self._process.wait() self.closed = True
[ "def", "_finish", "(", "self", ")", ":", "if", "self", ".", "_process", ".", "returncode", "is", "None", ":", "self", ".", "_process", ".", "stdin", ".", "flush", "(", ")", "self", ".", "_process", ".", "stdin", ".", "close", "(", ")", "self", ".",...
Closes and waits for subprocess to exit.
[ "Closes", "and", "waits", "for", "subprocess", "to", "exit", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/format.py#L197-L205
train
spotify/luigi
luigi/worker.py
check_complete
def check_complete(task, out_queue): """ Checks if task is complete, puts the result to out_queue. """ logger.debug("Checking if %s is complete", task) try: is_complete = task.complete() except Exception: is_complete = TracebackWrapper(traceback.format_exc()) out_queue.put((t...
python
def check_complete(task, out_queue): """ Checks if task is complete, puts the result to out_queue. """ logger.debug("Checking if %s is complete", task) try: is_complete = task.complete() except Exception: is_complete = TracebackWrapper(traceback.format_exc()) out_queue.put((t...
[ "def", "check_complete", "(", "task", ",", "out_queue", ")", ":", "logger", ".", "debug", "(", "\"Checking if %s is complete\"", ",", "task", ")", "try", ":", "is_complete", "=", "task", ".", "complete", "(", ")", "except", "Exception", ":", "is_complete", "...
Checks if task is complete, puts the result to out_queue.
[ "Checks", "if", "task", "is", "complete", "puts", "the", "result", "to", "out_queue", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/worker.py#L395-L404
train
spotify/luigi
luigi/worker.py
Worker._add_task
def _add_task(self, *args, **kwargs): """ Call ``self._scheduler.add_task``, but store the values too so we can implement :py:func:`luigi.execution_summary.summary`. """ task_id = kwargs['task_id'] status = kwargs['status'] runnable = kwargs['runnable'] ta...
python
def _add_task(self, *args, **kwargs): """ Call ``self._scheduler.add_task``, but store the values too so we can implement :py:func:`luigi.execution_summary.summary`. """ task_id = kwargs['task_id'] status = kwargs['status'] runnable = kwargs['runnable'] ta...
[ "def", "_add_task", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "task_id", "=", "kwargs", "[", "'task_id'", "]", "status", "=", "kwargs", "[", "'status'", "]", "runnable", "=", "kwargs", "[", "'runnable'", "]", "task", "=", "sel...
Call ``self._scheduler.add_task``, but store the values too so we can implement :py:func:`luigi.execution_summary.summary`.
[ "Call", "self", ".", "_scheduler", ".", "add_task", "but", "store", "the", "values", "too", "so", "we", "can", "implement", ":", "py", ":", "func", ":", "luigi", ".", "execution_summary", ".", "summary", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/worker.py#L561-L583
train
spotify/luigi
luigi/worker.py
Worker.add
def add(self, task, multiprocess=False, processes=0): """ Add a Task for the worker to check and possibly schedule and run. Returns True if task and its dependencies were successfully scheduled or completed before. """ if self._first_task is None and hasattr(task, 'task_id'): ...
python
def add(self, task, multiprocess=False, processes=0): """ Add a Task for the worker to check and possibly schedule and run. Returns True if task and its dependencies were successfully scheduled or completed before. """ if self._first_task is None and hasattr(task, 'task_id'): ...
[ "def", "add", "(", "self", ",", "task", ",", "multiprocess", "=", "False", ",", "processes", "=", "0", ")", ":", "if", "self", ".", "_first_task", "is", "None", "and", "hasattr", "(", "task", ",", "'task_id'", ")", ":", "self", ".", "_first_task", "=...
Add a Task for the worker to check and possibly schedule and run. Returns True if task and its dependencies were successfully scheduled or completed before.
[ "Add", "a", "Task", "for", "the", "worker", "to", "check", "and", "possibly", "schedule", "and", "run", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/worker.py#L725-L769
train
spotify/luigi
luigi/worker.py
Worker._purge_children
def _purge_children(self): """ Find dead children and put a response on the result queue. :return: """ for task_id, p in six.iteritems(self._running_tasks): if not p.is_alive() and p.exitcode: error_msg = 'Task {} died unexpectedly with exit code {}'....
python
def _purge_children(self): """ Find dead children and put a response on the result queue. :return: """ for task_id, p in six.iteritems(self._running_tasks): if not p.is_alive() and p.exitcode: error_msg = 'Task {} died unexpectedly with exit code {}'....
[ "def", "_purge_children", "(", "self", ")", ":", "for", "task_id", ",", "p", "in", "six", ".", "iteritems", "(", "self", ".", "_running_tasks", ")", ":", "if", "not", "p", ".", "is_alive", "(", ")", "and", "p", ".", "exitcode", ":", "error_msg", "=",...
Find dead children and put a response on the result queue. :return:
[ "Find", "dead", "children", "and", "put", "a", "response", "on", "the", "result", "queue", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/worker.py#L1021-L1039
train
spotify/luigi
luigi/worker.py
Worker._handle_next_task
def _handle_next_task(self): """ We have to catch three ways a task can be "done": 1. normal execution: the task runs/fails and puts a result back on the queue, 2. new dependencies: the task yielded new deps that were not complete and will be rescheduled and dependencies adde...
python
def _handle_next_task(self): """ We have to catch three ways a task can be "done": 1. normal execution: the task runs/fails and puts a result back on the queue, 2. new dependencies: the task yielded new deps that were not complete and will be rescheduled and dependencies adde...
[ "def", "_handle_next_task", "(", "self", ")", ":", "self", ".", "_idle_since", "=", "None", "while", "True", ":", "self", ".", "_purge_children", "(", ")", "# Deal with subprocess failures", "try", ":", "task_id", ",", "status", ",", "expl", ",", "missing", ...
We have to catch three ways a task can be "done": 1. normal execution: the task runs/fails and puts a result back on the queue, 2. new dependencies: the task yielded new deps that were not complete and will be rescheduled and dependencies added, 3. child process dies: we need to catc...
[ "We", "have", "to", "catch", "three", "ways", "a", "task", "can", "be", "done", ":" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/worker.py#L1041-L1109
train
spotify/luigi
luigi/worker.py
Worker._keep_alive
def _keep_alive(self, get_work_response): """ Returns true if a worker should stay alive given. If worker-keep-alive is not set, this will always return false. For an assistant, it will always return the value of worker-keep-alive. Otherwise, it will return true for nonzero n_pe...
python
def _keep_alive(self, get_work_response): """ Returns true if a worker should stay alive given. If worker-keep-alive is not set, this will always return false. For an assistant, it will always return the value of worker-keep-alive. Otherwise, it will return true for nonzero n_pe...
[ "def", "_keep_alive", "(", "self", ",", "get_work_response", ")", ":", "if", "not", "self", ".", "_config", ".", "keep_alive", ":", "return", "False", "elif", "self", ".", "_assistant", ":", "return", "True", "elif", "self", ".", "_config", ".", "count_las...
Returns true if a worker should stay alive given. If worker-keep-alive is not set, this will always return false. For an assistant, it will always return the value of worker-keep-alive. Otherwise, it will return true for nonzero n_pending_tasks. If worker-count-uniques is true, it will...
[ "Returns", "true", "if", "a", "worker", "should", "stay", "alive", "given", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/worker.py#L1120-L1148
train
spotify/luigi
luigi/worker.py
Worker.run
def run(self): """ Returns True if all scheduled tasks were executed successfully. """ logger.info('Running Worker with %d processes', self.worker_processes) sleeper = self._sleeper() self.run_succeeded = True self._add_worker() while True: ...
python
def run(self): """ Returns True if all scheduled tasks were executed successfully. """ logger.info('Running Worker with %d processes', self.worker_processes) sleeper = self._sleeper() self.run_succeeded = True self._add_worker() while True: ...
[ "def", "run", "(", "self", ")", ":", "logger", ".", "info", "(", "'Running Worker with %d processes'", ",", "self", ".", "worker_processes", ")", "sleeper", "=", "self", ".", "_sleeper", "(", ")", "self", ".", "run_succeeded", "=", "True", "self", ".", "_a...
Returns True if all scheduled tasks were executed successfully.
[ "Returns", "True", "if", "all", "scheduled", "tasks", "were", "executed", "successfully", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/worker.py#L1165-L1208
train
spotify/luigi
luigi/db_task_history.py
_upgrade_schema
def _upgrade_schema(engine): """ Ensure the database schema is up to date with the codebase. :param engine: SQLAlchemy engine of the underlying database. """ inspector = reflection.Inspector.from_engine(engine) with engine.connect() as conn: # Upgrade 1. Add task_id column and index t...
python
def _upgrade_schema(engine): """ Ensure the database schema is up to date with the codebase. :param engine: SQLAlchemy engine of the underlying database. """ inspector = reflection.Inspector.from_engine(engine) with engine.connect() as conn: # Upgrade 1. Add task_id column and index t...
[ "def", "_upgrade_schema", "(", "engine", ")", ":", "inspector", "=", "reflection", ".", "Inspector", ".", "from_engine", "(", "engine", ")", "with", "engine", ".", "connect", "(", ")", "as", "conn", ":", "# Upgrade 1. Add task_id column and index to tasks", "if",...
Ensure the database schema is up to date with the codebase. :param engine: SQLAlchemy engine of the underlying database.
[ "Ensure", "the", "database", "schema", "is", "up", "to", "date", "with", "the", "codebase", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/db_task_history.py#L243-L283
train
spotify/luigi
luigi/db_task_history.py
DbTaskHistory.find_all_by_parameters
def find_all_by_parameters(self, task_name, session=None, **task_params): """ Find tasks with the given task_name and the same parameters as the kwargs. """ with self._session(session) as session: query = session.query(TaskRecord).join(TaskEvent).filter(TaskRecord.name == tas...
python
def find_all_by_parameters(self, task_name, session=None, **task_params): """ Find tasks with the given task_name and the same parameters as the kwargs. """ with self._session(session) as session: query = session.query(TaskRecord).join(TaskEvent).filter(TaskRecord.name == tas...
[ "def", "find_all_by_parameters", "(", "self", ",", "task_name", ",", "session", "=", "None", ",", "*", "*", "task_params", ")", ":", "with", "self", ".", "_session", "(", "session", ")", "as", "session", ":", "query", "=", "session", ".", "query", "(", ...
Find tasks with the given task_name and the same parameters as the kwargs.
[ "Find", "tasks", "with", "the", "given", "task_name", "and", "the", "same", "parameters", "as", "the", "kwargs", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/db_task_history.py#L134-L149
train
spotify/luigi
luigi/db_task_history.py
DbTaskHistory.find_all_runs
def find_all_runs(self, session=None): """ Return all tasks that have been updated. """ with self._session(session) as session: return session.query(TaskRecord).all()
python
def find_all_runs(self, session=None): """ Return all tasks that have been updated. """ with self._session(session) as session: return session.query(TaskRecord).all()
[ "def", "find_all_runs", "(", "self", ",", "session", "=", "None", ")", ":", "with", "self", ".", "_session", "(", "session", ")", "as", "session", ":", "return", "session", ".", "query", "(", "TaskRecord", ")", ".", "all", "(", ")" ]
Return all tasks that have been updated.
[ "Return", "all", "tasks", "that", "have", "been", "updated", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/db_task_history.py#L170-L175
train
spotify/luigi
luigi/db_task_history.py
DbTaskHistory.find_all_events
def find_all_events(self, session=None): """ Return all running/failed/done events. """ with self._session(session) as session: return session.query(TaskEvent).all()
python
def find_all_events(self, session=None): """ Return all running/failed/done events. """ with self._session(session) as session: return session.query(TaskEvent).all()
[ "def", "find_all_events", "(", "self", ",", "session", "=", "None", ")", ":", "with", "self", ".", "_session", "(", "session", ")", "as", "session", ":", "return", "session", ".", "query", "(", "TaskEvent", ")", ".", "all", "(", ")" ]
Return all running/failed/done events.
[ "Return", "all", "running", "/", "failed", "/", "done", "events", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/db_task_history.py#L177-L182
train
spotify/luigi
luigi/db_task_history.py
DbTaskHistory.find_task_by_id
def find_task_by_id(self, id, session=None): """ Find task with the given record ID. """ with self._session(session) as session: return session.query(TaskRecord).get(id)
python
def find_task_by_id(self, id, session=None): """ Find task with the given record ID. """ with self._session(session) as session: return session.query(TaskRecord).get(id)
[ "def", "find_task_by_id", "(", "self", ",", "id", ",", "session", "=", "None", ")", ":", "with", "self", ".", "_session", "(", "session", ")", "as", "session", ":", "return", "session", ".", "query", "(", "TaskRecord", ")", ".", "get", "(", "id", ")"...
Find task with the given record ID.
[ "Find", "task", "with", "the", "given", "record", "ID", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/db_task_history.py#L184-L189
train
spotify/luigi
luigi/contrib/gcp.py
get_authenticate_kwargs
def get_authenticate_kwargs(oauth_credentials=None, http_=None): """Returns a dictionary with keyword arguments for use with discovery Prioritizes oauth_credentials or a http client provided by the user If none provided, falls back to default credentials provided by google's command line utilities. If ...
python
def get_authenticate_kwargs(oauth_credentials=None, http_=None): """Returns a dictionary with keyword arguments for use with discovery Prioritizes oauth_credentials or a http client provided by the user If none provided, falls back to default credentials provided by google's command line utilities. If ...
[ "def", "get_authenticate_kwargs", "(", "oauth_credentials", "=", "None", ",", "http_", "=", "None", ")", ":", "if", "oauth_credentials", ":", "authenticate_kwargs", "=", "{", "\"credentials\"", ":", "oauth_credentials", "}", "elif", "http_", ":", "authenticate_kwarg...
Returns a dictionary with keyword arguments for use with discovery Prioritizes oauth_credentials or a http client provided by the user If none provided, falls back to default credentials provided by google's command line utilities. If that also fails, tries using httplib2.Http() Used by `gcs.GCSClient...
[ "Returns", "a", "dictionary", "with", "keyword", "arguments", "for", "use", "with", "discovery" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/gcp.py#L15-L46
train
spotify/luigi
luigi/contrib/redshift.py
_CredentialsMixin._credentials
def _credentials(self): """ Return a credential string for the provided task. If no valid credentials are set, raise a NotImplementedError. """ if self.aws_account_id and self.aws_arn_role_name: return 'aws_iam_role=arn:aws:iam::{id}:role/{role}'.format( ...
python
def _credentials(self): """ Return a credential string for the provided task. If no valid credentials are set, raise a NotImplementedError. """ if self.aws_account_id and self.aws_arn_role_name: return 'aws_iam_role=arn:aws:iam::{id}:role/{role}'.format( ...
[ "def", "_credentials", "(", "self", ")", ":", "if", "self", ".", "aws_account_id", "and", "self", ".", "aws_arn_role_name", ":", "return", "'aws_iam_role=arn:aws:iam::{id}:role/{role}'", ".", "format", "(", "id", "=", "self", ".", "aws_account_id", ",", "role", ...
Return a credential string for the provided task. If no valid credentials are set, raise a NotImplementedError.
[ "Return", "a", "credential", "string", "for", "the", "provided", "task", ".", "If", "no", "valid", "credentials", "are", "set", "raise", "a", "NotImplementedError", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L100-L123
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.do_prune
def do_prune(self): """ Return True if prune_table, prune_column, and prune_date are implemented. If only a subset of prune variables are override, an exception is raised to remind the user to implement all or none. Prune (data newer than prune_date deleted) before copying new data in. ...
python
def do_prune(self): """ Return True if prune_table, prune_column, and prune_date are implemented. If only a subset of prune variables are override, an exception is raised to remind the user to implement all or none. Prune (data newer than prune_date deleted) before copying new data in. ...
[ "def", "do_prune", "(", "self", ")", ":", "if", "self", ".", "prune_table", "and", "self", ".", "prune_column", "and", "self", ".", "prune_date", ":", "return", "True", "elif", "self", ".", "prune_table", "or", "self", ".", "prune_column", "or", "self", ...
Return True if prune_table, prune_column, and prune_date are implemented. If only a subset of prune variables are override, an exception is raised to remind the user to implement all or none. Prune (data newer than prune_date deleted) before copying new data in.
[ "Return", "True", "if", "prune_table", "prune_column", "and", "prune_date", "are", "implemented", ".", "If", "only", "a", "subset", "of", "prune", "variables", "are", "override", "an", "exception", "is", "raised", "to", "remind", "the", "user", "to", "implemen...
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L240-L251
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.create_schema
def create_schema(self, connection): """ Will create the schema in the database """ if '.' not in self.table: return query = 'CREATE SCHEMA IF NOT EXISTS {schema_name};'.format(schema_name=self.table.split('.')[0]) connection.cursor().execute(query)
python
def create_schema(self, connection): """ Will create the schema in the database """ if '.' not in self.table: return query = 'CREATE SCHEMA IF NOT EXISTS {schema_name};'.format(schema_name=self.table.split('.')[0]) connection.cursor().execute(query)
[ "def", "create_schema", "(", "self", ",", "connection", ")", ":", "if", "'.'", "not", "in", "self", ".", "table", ":", "return", "query", "=", "'CREATE SCHEMA IF NOT EXISTS {schema_name};'", ".", "format", "(", "schema_name", "=", "self", ".", "table", ".", ...
Will create the schema in the database
[ "Will", "create", "the", "schema", "in", "the", "database" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L283-L291
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.create_table
def create_table(self, connection): """ Override to provide code for creating the target table. By default it will be created using types (optionally) specified in columns. If overridden, use the provided connection object for setting up the table in order to create the...
python
def create_table(self, connection): """ Override to provide code for creating the target table. By default it will be created using types (optionally) specified in columns. If overridden, use the provided connection object for setting up the table in order to create the...
[ "def", "create_table", "(", "self", ",", "connection", ")", ":", "if", "len", "(", "self", ".", "columns", "[", "0", "]", ")", "==", "1", ":", "# only names of columns specified, no types", "raise", "NotImplementedError", "(", "\"create_table() not implemented \"", ...
Override to provide code for creating the target table. By default it will be created using types (optionally) specified in columns. If overridden, use the provided connection object for setting up the table in order to create the table and insert data using the same transactio...
[ "Override", "to", "provide", "code", "for", "creating", "the", "target", "table", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L293-L357
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.run
def run(self): """ If the target table doesn't exist, self.create_table will be called to attempt to create the table. """ if not (self.table): raise Exception("table need to be specified") path = self.s3_load_path() output = self.output() con...
python
def run(self): """ If the target table doesn't exist, self.create_table will be called to attempt to create the table. """ if not (self.table): raise Exception("table need to be specified") path = self.s3_load_path() output = self.output() con...
[ "def", "run", "(", "self", ")", ":", "if", "not", "(", "self", ".", "table", ")", ":", "raise", "Exception", "(", "\"table need to be specified\"", ")", "path", "=", "self", ".", "s3_load_path", "(", ")", "output", "=", "self", ".", "output", "(", ")",...
If the target table doesn't exist, self.create_table will be called to attempt to create the table.
[ "If", "the", "target", "table", "doesn", "t", "exist", "self", ".", "create_table", "will", "be", "called", "to", "attempt", "to", "create", "the", "table", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L359-L384
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.copy
def copy(self, cursor, f): """ Defines copying from s3 into redshift. If both key-based and role-based credentials are provided, role-based will be used. """ logger.info("Inserting file: %s", f) colnames = '' if self.columns and len(self.columns) > 0: ...
python
def copy(self, cursor, f): """ Defines copying from s3 into redshift. If both key-based and role-based credentials are provided, role-based will be used. """ logger.info("Inserting file: %s", f) colnames = '' if self.columns and len(self.columns) > 0: ...
[ "def", "copy", "(", "self", ",", "cursor", ",", "f", ")", ":", "logger", ".", "info", "(", "\"Inserting file: %s\"", ",", "f", ")", "colnames", "=", "''", "if", "self", ".", "columns", "and", "len", "(", "self", ".", "columns", ")", ">", "0", ":", ...
Defines copying from s3 into redshift. If both key-based and role-based credentials are provided, role-based will be used.
[ "Defines", "copying", "from", "s3", "into", "redshift", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L386-L408
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.does_schema_exist
def does_schema_exist(self, connection): """ Determine whether the schema already exists. """ if '.' in self.table: query = ("select 1 as schema_exists " "from pg_namespace " "where nspname = lower(%s) limit 1") else: ...
python
def does_schema_exist(self, connection): """ Determine whether the schema already exists. """ if '.' in self.table: query = ("select 1 as schema_exists " "from pg_namespace " "where nspname = lower(%s) limit 1") else: ...
[ "def", "does_schema_exist", "(", "self", ",", "connection", ")", ":", "if", "'.'", "in", "self", ".", "table", ":", "query", "=", "(", "\"select 1 as schema_exists \"", "\"from pg_namespace \"", "\"where nspname = lower(%s) limit 1\"", ")", "else", ":", "return", "T...
Determine whether the schema already exists.
[ "Determine", "whether", "the", "schema", "already", "exists", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L424-L443
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.does_table_exist
def does_table_exist(self, connection): """ Determine whether the table already exists. """ if '.' in self.table: query = ("select 1 as table_exists " "from information_schema.tables " "where table_schema = lower(%s) and table_name =...
python
def does_table_exist(self, connection): """ Determine whether the table already exists. """ if '.' in self.table: query = ("select 1 as table_exists " "from information_schema.tables " "where table_schema = lower(%s) and table_name =...
[ "def", "does_table_exist", "(", "self", ",", "connection", ")", ":", "if", "'.'", "in", "self", ".", "table", ":", "query", "=", "(", "\"select 1 as table_exists \"", "\"from information_schema.tables \"", "\"where table_schema = lower(%s) and table_name = lower(%s) limit 1\"...
Determine whether the table already exists.
[ "Determine", "whether", "the", "table", "already", "exists", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L445-L464
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.init_copy
def init_copy(self, connection): """ Perform pre-copy sql - such as creating table, truncating, or removing data older than x. """ if not self.does_schema_exist(connection): logger.info("Creating schema for %s", self.table) self.create_schema(connection) ...
python
def init_copy(self, connection): """ Perform pre-copy sql - such as creating table, truncating, or removing data older than x. """ if not self.does_schema_exist(connection): logger.info("Creating schema for %s", self.table) self.create_schema(connection) ...
[ "def", "init_copy", "(", "self", ",", "connection", ")", ":", "if", "not", "self", ".", "does_schema_exist", "(", "connection", ")", ":", "logger", ".", "info", "(", "\"Creating schema for %s\"", ",", "self", ".", "table", ")", "self", ".", "create_schema", ...
Perform pre-copy sql - such as creating table, truncating, or removing data older than x.
[ "Perform", "pre", "-", "copy", "sql", "-", "such", "as", "creating", "table", "truncating", "or", "removing", "data", "older", "than", "x", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L466-L487
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.post_copy
def post_copy(self, cursor): """ Performs post-copy sql - such as cleansing data, inserting into production table (if copied to temp table), etc. """ logger.info('Executing post copy queries') for query in self.queries: cursor.execute(query)
python
def post_copy(self, cursor): """ Performs post-copy sql - such as cleansing data, inserting into production table (if copied to temp table), etc. """ logger.info('Executing post copy queries') for query in self.queries: cursor.execute(query)
[ "def", "post_copy", "(", "self", ",", "cursor", ")", ":", "logger", ".", "info", "(", "'Executing post copy queries'", ")", "for", "query", "in", "self", ".", "queries", ":", "cursor", ".", "execute", "(", "query", ")" ]
Performs post-copy sql - such as cleansing data, inserting into production table (if copied to temp table), etc.
[ "Performs", "post", "-", "copy", "sql", "-", "such", "as", "cleansing", "data", "inserting", "into", "production", "table", "(", "if", "copied", "to", "temp", "table", ")", "etc", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L489-L495
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyToTable.post_copy_metacolums
def post_copy_metacolums(self, cursor): """ Performs post-copy to fill metadata columns. """ logger.info('Executing post copy metadata queries') for query in self.metadata_queries: cursor.execute(query)
python
def post_copy_metacolums(self, cursor): """ Performs post-copy to fill metadata columns. """ logger.info('Executing post copy metadata queries') for query in self.metadata_queries: cursor.execute(query)
[ "def", "post_copy_metacolums", "(", "self", ",", "cursor", ")", ":", "logger", ".", "info", "(", "'Executing post copy metadata queries'", ")", "for", "query", "in", "self", ".", "metadata_queries", ":", "cursor", ".", "execute", "(", "query", ")" ]
Performs post-copy to fill metadata columns.
[ "Performs", "post", "-", "copy", "to", "fill", "metadata", "columns", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L497-L503
train
spotify/luigi
luigi/contrib/redshift.py
S3CopyJSONToTable.copy
def copy(self, cursor, f): """ Defines copying JSON from s3 into redshift. """ logger.info("Inserting file: %s", f) cursor.execute(""" COPY %s from '%s' CREDENTIALS '%s' JSON AS '%s' %s %s ;""" % (self.table, f, self._credentials(), ...
python
def copy(self, cursor, f): """ Defines copying JSON from s3 into redshift. """ logger.info("Inserting file: %s", f) cursor.execute(""" COPY %s from '%s' CREDENTIALS '%s' JSON AS '%s' %s %s ;""" % (self.table, f, self._credentials(), ...
[ "def", "copy", "(", "self", ",", "cursor", ",", "f", ")", ":", "logger", ".", "info", "(", "\"Inserting file: %s\"", ",", "f", ")", "cursor", ".", "execute", "(", "\"\"\"\n COPY %s from '%s'\n CREDENTIALS '%s'\n JSON AS '%s' %s\n %s\n ...
Defines copying JSON from s3 into redshift.
[ "Defines", "copying", "JSON", "from", "s3", "into", "redshift", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L546-L558
train
spotify/luigi
luigi/contrib/redshift.py
KillOpenRedshiftSessions.output
def output(self): """ Returns a RedshiftTarget representing the inserted dataset. Normally you don't override this. """ # uses class name as a meta-table return RedshiftTarget( host=self.host, database=self.database, user=self.user, ...
python
def output(self): """ Returns a RedshiftTarget representing the inserted dataset. Normally you don't override this. """ # uses class name as a meta-table return RedshiftTarget( host=self.host, database=self.database, user=self.user, ...
[ "def", "output", "(", "self", ")", ":", "# uses class name as a meta-table", "return", "RedshiftTarget", "(", "host", "=", "self", ".", "host", ",", "database", "=", "self", ".", "database", ",", "user", "=", "self", ".", "user", ",", "password", "=", "sel...
Returns a RedshiftTarget representing the inserted dataset. Normally you don't override this.
[ "Returns", "a", "RedshiftTarget", "representing", "the", "inserted", "dataset", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L649-L662
train
spotify/luigi
luigi/contrib/redshift.py
KillOpenRedshiftSessions.run
def run(self): """ Kill any open Redshift sessions for the given database. """ connection = self.output().connect() # kill any sessions other than ours and # internal Redshift sessions (rdsdb) query = ("select pg_terminate_backend(process) " "from...
python
def run(self): """ Kill any open Redshift sessions for the given database. """ connection = self.output().connect() # kill any sessions other than ours and # internal Redshift sessions (rdsdb) query = ("select pg_terminate_backend(process) " "from...
[ "def", "run", "(", "self", ")", ":", "connection", "=", "self", ".", "output", "(", ")", ".", "connect", "(", ")", "# kill any sessions other than ours and", "# internal Redshift sessions (rdsdb)", "query", "=", "(", "\"select pg_terminate_backend(process) \"", "\"from ...
Kill any open Redshift sessions for the given database.
[ "Kill", "any", "open", "Redshift", "sessions", "for", "the", "given", "database", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/redshift.py#L664-L701
train
spotify/luigi
luigi/date_interval.py
DateInterval.dates
def dates(self): ''' Returns a list of dates in this date interval.''' dates = [] d = self.date_a while d < self.date_b: dates.append(d) d += datetime.timedelta(1) return dates
python
def dates(self): ''' Returns a list of dates in this date interval.''' dates = [] d = self.date_a while d < self.date_b: dates.append(d) d += datetime.timedelta(1) return dates
[ "def", "dates", "(", "self", ")", ":", "dates", "=", "[", "]", "d", "=", "self", ".", "date_a", "while", "d", "<", "self", ".", "date_b", ":", "dates", ".", "append", "(", "d", ")", "d", "+=", "datetime", ".", "timedelta", "(", "1", ")", "retur...
Returns a list of dates in this date interval.
[ "Returns", "a", "list", "of", "dates", "in", "this", "date", "interval", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/date_interval.py#L67-L75
train
spotify/luigi
luigi/date_interval.py
DateInterval.hours
def hours(self): ''' Same as dates() but returns 24 times more info: one for each hour.''' for date in self.dates(): for hour in xrange(24): yield datetime.datetime.combine(date, datetime.time(hour))
python
def hours(self): ''' Same as dates() but returns 24 times more info: one for each hour.''' for date in self.dates(): for hour in xrange(24): yield datetime.datetime.combine(date, datetime.time(hour))
[ "def", "hours", "(", "self", ")", ":", "for", "date", "in", "self", ".", "dates", "(", ")", ":", "for", "hour", "in", "xrange", "(", "24", ")", ":", "yield", "datetime", ".", "datetime", ".", "combine", "(", "date", ",", "datetime", ".", "time", ...
Same as dates() but returns 24 times more info: one for each hour.
[ "Same", "as", "dates", "()", "but", "returns", "24", "times", "more", "info", ":", "one", "for", "each", "hour", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/date_interval.py#L77-L81
train
spotify/luigi
examples/ftp_experiment_outputs.py
ExperimentTask.run
def run(self): """ The execution of this task will write 4 lines of data on this task's target output. """ with self.output().open('w') as outfile: print("data 0 200 10 50 60", file=outfile) print("data 1 190 9 52 60", file=outfile) print("data 2 200 1...
python
def run(self): """ The execution of this task will write 4 lines of data on this task's target output. """ with self.output().open('w') as outfile: print("data 0 200 10 50 60", file=outfile) print("data 1 190 9 52 60", file=outfile) print("data 2 200 1...
[ "def", "run", "(", "self", ")", ":", "with", "self", ".", "output", "(", ")", ".", "open", "(", "'w'", ")", "as", "outfile", ":", "print", "(", "\"data 0 200 10 50 60\"", ",", "file", "=", "outfile", ")", "print", "(", "\"data 1 190 9 52 60\"", ",", "f...
The execution of this task will write 4 lines of data on this task's target output.
[ "The", "execution", "of", "this", "task", "will", "write", "4", "lines", "of", "data", "on", "this", "task", "s", "target", "output", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/examples/ftp_experiment_outputs.py#L46-L54
train
spotify/luigi
luigi/mock.py
MockFileSystem.copy
def copy(self, path, dest, raise_if_exists=False): """ Copies the contents of a single file path to dest """ if raise_if_exists and dest in self.get_all_data(): raise RuntimeError('Destination exists: %s' % path) contents = self.get_all_data()[path] self.get_a...
python
def copy(self, path, dest, raise_if_exists=False): """ Copies the contents of a single file path to dest """ if raise_if_exists and dest in self.get_all_data(): raise RuntimeError('Destination exists: %s' % path) contents = self.get_all_data()[path] self.get_a...
[ "def", "copy", "(", "self", ",", "path", ",", "dest", ",", "raise_if_exists", "=", "False", ")", ":", "if", "raise_if_exists", "and", "dest", "in", "self", ".", "get_all_data", "(", ")", ":", "raise", "RuntimeError", "(", "'Destination exists: %s'", "%", "...
Copies the contents of a single file path to dest
[ "Copies", "the", "contents", "of", "a", "single", "file", "path", "to", "dest" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/mock.py#L40-L47
train
spotify/luigi
luigi/mock.py
MockFileSystem.remove
def remove(self, path, recursive=True, skip_trash=True): """ Removes the given mockfile. skip_trash doesn't have any meaning. """ if recursive: to_delete = [] for s in self.get_all_data().keys(): if s.startswith(path): to_delete...
python
def remove(self, path, recursive=True, skip_trash=True): """ Removes the given mockfile. skip_trash doesn't have any meaning. """ if recursive: to_delete = [] for s in self.get_all_data().keys(): if s.startswith(path): to_delete...
[ "def", "remove", "(", "self", ",", "path", ",", "recursive", "=", "True", ",", "skip_trash", "=", "True", ")", ":", "if", "recursive", ":", "to_delete", "=", "[", "]", "for", "s", "in", "self", ".", "get_all_data", "(", ")", ".", "keys", "(", ")", ...
Removes the given mockfile. skip_trash doesn't have any meaning.
[ "Removes", "the", "given", "mockfile", ".", "skip_trash", "doesn", "t", "have", "any", "meaning", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/mock.py#L61-L73
train
spotify/luigi
luigi/mock.py
MockFileSystem.move
def move(self, path, dest, raise_if_exists=False): """ Moves a single file from path to dest """ if raise_if_exists and dest in self.get_all_data(): raise RuntimeError('Destination exists: %s' % path) contents = self.get_all_data().pop(path) self.get_all_data(...
python
def move(self, path, dest, raise_if_exists=False): """ Moves a single file from path to dest """ if raise_if_exists and dest in self.get_all_data(): raise RuntimeError('Destination exists: %s' % path) contents = self.get_all_data().pop(path) self.get_all_data(...
[ "def", "move", "(", "self", ",", "path", ",", "dest", ",", "raise_if_exists", "=", "False", ")", ":", "if", "raise_if_exists", "and", "dest", "in", "self", ".", "get_all_data", "(", ")", ":", "raise", "RuntimeError", "(", "'Destination exists: %s'", "%", "...
Moves a single file from path to dest
[ "Moves", "a", "single", "file", "from", "path", "to", "dest" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/mock.py#L75-L82
train
spotify/luigi
luigi/mock.py
MockFileSystem.listdir
def listdir(self, path): """ listdir does a prefix match of self.get_all_data(), but doesn't yet support globs. """ return [s for s in self.get_all_data().keys() if s.startswith(path)]
python
def listdir(self, path): """ listdir does a prefix match of self.get_all_data(), but doesn't yet support globs. """ return [s for s in self.get_all_data().keys() if s.startswith(path)]
[ "def", "listdir", "(", "self", ",", "path", ")", ":", "return", "[", "s", "for", "s", "in", "self", ".", "get_all_data", "(", ")", ".", "keys", "(", ")", "if", "s", ".", "startswith", "(", "path", ")", "]" ]
listdir does a prefix match of self.get_all_data(), but doesn't yet support globs.
[ "listdir", "does", "a", "prefix", "match", "of", "self", ".", "get_all_data", "()", "but", "doesn", "t", "yet", "support", "globs", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/mock.py#L84-L89
train
spotify/luigi
luigi/mock.py
MockTarget.move
def move(self, path, raise_if_exists=False): """ Call MockFileSystem's move command """ self.fs.move(self.path, path, raise_if_exists)
python
def move(self, path, raise_if_exists=False): """ Call MockFileSystem's move command """ self.fs.move(self.path, path, raise_if_exists)
[ "def", "move", "(", "self", ",", "path", ",", "raise_if_exists", "=", "False", ")", ":", "self", ".", "fs", ".", "move", "(", "self", ".", "path", ",", "path", ",", "raise_if_exists", ")" ]
Call MockFileSystem's move command
[ "Call", "MockFileSystem", "s", "move", "command" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/mock.py#L122-L126
train
spotify/luigi
luigi/parameter.py
_recursively_freeze
def _recursively_freeze(value): """ Recursively walks ``Mapping``s and ``list``s and converts them to ``_FrozenOrderedDict`` and ``tuples``, respectively. """ if isinstance(value, Mapping): return _FrozenOrderedDict(((k, _recursively_freeze(v)) for k, v in value.items())) elif isinstance(val...
python
def _recursively_freeze(value): """ Recursively walks ``Mapping``s and ``list``s and converts them to ``_FrozenOrderedDict`` and ``tuples``, respectively. """ if isinstance(value, Mapping): return _FrozenOrderedDict(((k, _recursively_freeze(v)) for k, v in value.items())) elif isinstance(val...
[ "def", "_recursively_freeze", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Mapping", ")", ":", "return", "_FrozenOrderedDict", "(", "(", "(", "k", ",", "_recursively_freeze", "(", "v", ")", ")", "for", "k", ",", "v", "in", "value", "...
Recursively walks ``Mapping``s and ``list``s and converts them to ``_FrozenOrderedDict`` and ``tuples``, respectively.
[ "Recursively", "walks", "Mapping", "s", "and", "list", "s", "and", "converts", "them", "to", "_FrozenOrderedDict", "and", "tuples", "respectively", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L929-L937
train
spotify/luigi
luigi/parameter.py
Parameter._get_value_from_config
def _get_value_from_config(self, section, name): """Loads the default from the config. Returns _no_value if it doesn't exist""" conf = configuration.get_config() try: value = conf.get(section, name) except (NoSectionError, NoOptionError, KeyError): return _no_va...
python
def _get_value_from_config(self, section, name): """Loads the default from the config. Returns _no_value if it doesn't exist""" conf = configuration.get_config() try: value = conf.get(section, name) except (NoSectionError, NoOptionError, KeyError): return _no_va...
[ "def", "_get_value_from_config", "(", "self", ",", "section", ",", "name", ")", ":", "conf", "=", "configuration", ".", "get_config", "(", ")", "try", ":", "value", "=", "conf", ".", "get", "(", "section", ",", "name", ")", "except", "(", "NoSectionError...
Loads the default from the config. Returns _no_value if it doesn't exist
[ "Loads", "the", "default", "from", "the", "config", ".", "Returns", "_no_value", "if", "it", "doesn", "t", "exist" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L192-L202
train
spotify/luigi
luigi/parameter.py
Parameter._value_iterator
def _value_iterator(self, task_name, param_name): """ Yield the parameter values, with optional deprecation warning as second tuple value. The parameter value will be whatever non-_no_value that is yielded first. """ cp_parser = CmdlineParser.get_instance() if cp_parser:...
python
def _value_iterator(self, task_name, param_name): """ Yield the parameter values, with optional deprecation warning as second tuple value. The parameter value will be whatever non-_no_value that is yielded first. """ cp_parser = CmdlineParser.get_instance() if cp_parser:...
[ "def", "_value_iterator", "(", "self", ",", "task_name", ",", "param_name", ")", ":", "cp_parser", "=", "CmdlineParser", ".", "get_instance", "(", ")", "if", "cp_parser", ":", "dest", "=", "self", ".", "_parser_global_dest", "(", "param_name", ",", "task_name"...
Yield the parameter values, with optional deprecation warning as second tuple value. The parameter value will be whatever non-_no_value that is yielded first.
[ "Yield", "the", "parameter", "values", "with", "optional", "deprecation", "warning", "as", "second", "tuple", "value", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L212-L228
train
spotify/luigi
luigi/parameter.py
Parameter._parse_list
def _parse_list(self, xs): """ Parse a list of values from the scheduler. Only possible if this is_batchable() is True. This will combine the list into a single parameter value using batch method. This should never need to be overridden. :param xs: list of values to parse and c...
python
def _parse_list(self, xs): """ Parse a list of values from the scheduler. Only possible if this is_batchable() is True. This will combine the list into a single parameter value using batch method. This should never need to be overridden. :param xs: list of values to parse and c...
[ "def", "_parse_list", "(", "self", ",", "xs", ")", ":", "if", "not", "self", ".", "_is_batchable", "(", ")", ":", "raise", "NotImplementedError", "(", "'No batch method found'", ")", "elif", "not", "xs", ":", "raise", "ValueError", "(", "'Empty parameter list ...
Parse a list of values from the scheduler. Only possible if this is_batchable() is True. This will combine the list into a single parameter value using batch method. This should never need to be overridden. :param xs: list of values to parse and combine :return: the combined parsed val...
[ "Parse", "a", "list", "of", "values", "from", "the", "scheduler", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L255-L270
train
spotify/luigi
luigi/parameter.py
_DateParameterBase.parse
def parse(self, s): """ Parses a date string formatted like ``YYYY-MM-DD``. """ return datetime.datetime.strptime(s, self.date_format).date()
python
def parse(self, s): """ Parses a date string formatted like ``YYYY-MM-DD``. """ return datetime.datetime.strptime(s, self.date_format).date()
[ "def", "parse", "(", "self", ",", "s", ")", ":", "return", "datetime", ".", "datetime", ".", "strptime", "(", "s", ",", "self", ".", "date_format", ")", ".", "date", "(", ")" ]
Parses a date string formatted like ``YYYY-MM-DD``.
[ "Parses", "a", "date", "string", "formatted", "like", "YYYY", "-", "MM", "-", "DD", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L373-L377
train
spotify/luigi
luigi/parameter.py
_DateParameterBase.serialize
def serialize(self, dt): """ Converts the date to a string using the :py:attr:`~_DateParameterBase.date_format`. """ if dt is None: return str(dt) return dt.strftime(self.date_format)
python
def serialize(self, dt): """ Converts the date to a string using the :py:attr:`~_DateParameterBase.date_format`. """ if dt is None: return str(dt) return dt.strftime(self.date_format)
[ "def", "serialize", "(", "self", ",", "dt", ")", ":", "if", "dt", "is", "None", ":", "return", "str", "(", "dt", ")", "return", "dt", ".", "strftime", "(", "self", ".", "date_format", ")" ]
Converts the date to a string using the :py:attr:`~_DateParameterBase.date_format`.
[ "Converts", "the", "date", "to", "a", "string", "using", "the", ":", "py", ":", "attr", ":", "~_DateParameterBase", ".", "date_format", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L379-L385
train
spotify/luigi
luigi/parameter.py
MonthParameter._add_months
def _add_months(self, date, months): """ Add ``months`` months to ``date``. Unfortunately we can't use timedeltas to add months because timedelta counts in days and there's no foolproof way to add N months in days without counting the number of days per month. """ ...
python
def _add_months(self, date, months): """ Add ``months`` months to ``date``. Unfortunately we can't use timedeltas to add months because timedelta counts in days and there's no foolproof way to add N months in days without counting the number of days per month. """ ...
[ "def", "_add_months", "(", "self", ",", "date", ",", "months", ")", ":", "year", "=", "date", ".", "year", "+", "(", "date", ".", "month", "+", "months", "-", "1", ")", "//", "12", "month", "=", "(", "date", ".", "month", "+", "months", "-", "1...
Add ``months`` months to ``date``. Unfortunately we can't use timedeltas to add months because timedelta counts in days and there's no foolproof way to add N months in days without counting the number of days per month.
[ "Add", "months", "months", "to", "date", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L447-L457
train
spotify/luigi
luigi/parameter.py
_DatetimeParameterBase.normalize
def normalize(self, dt): """ Clamp dt to every Nth :py:attr:`~_DatetimeParameterBase.interval` starting at :py:attr:`~_DatetimeParameterBase.start`. """ if dt is None: return None dt = self._convert_to_dt(dt) dt = dt.replace(microsecond=0) # remove ...
python
def normalize(self, dt): """ Clamp dt to every Nth :py:attr:`~_DatetimeParameterBase.interval` starting at :py:attr:`~_DatetimeParameterBase.start`. """ if dt is None: return None dt = self._convert_to_dt(dt) dt = dt.replace(microsecond=0) # remove ...
[ "def", "normalize", "(", "self", ",", "dt", ")", ":", "if", "dt", "is", "None", ":", "return", "None", "dt", "=", "self", ".", "_convert_to_dt", "(", "dt", ")", "dt", "=", "dt", ".", "replace", "(", "microsecond", "=", "0", ")", "# remove microsecond...
Clamp dt to every Nth :py:attr:`~_DatetimeParameterBase.interval` starting at :py:attr:`~_DatetimeParameterBase.start`.
[ "Clamp", "dt", "to", "every", "Nth", ":", "py", ":", "attr", ":", "~_DatetimeParameterBase", ".", "interval", "starting", "at", ":", "py", ":", "attr", ":", "~_DatetimeParameterBase", ".", "start", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L544-L557
train
spotify/luigi
luigi/parameter.py
BoolParameter.parse
def parse(self, val): """ Parses a ``bool`` from the string, matching 'true' or 'false' ignoring case. """ s = str(val).lower() if s == "true": return True elif s == "false": return False else: raise ValueError("cannot interpret...
python
def parse(self, val): """ Parses a ``bool`` from the string, matching 'true' or 'false' ignoring case. """ s = str(val).lower() if s == "true": return True elif s == "false": return False else: raise ValueError("cannot interpret...
[ "def", "parse", "(", "self", ",", "val", ")", ":", "s", "=", "str", "(", "val", ")", ".", "lower", "(", ")", "if", "s", "==", "\"true\"", ":", "return", "True", "elif", "s", "==", "\"false\"", ":", "return", "False", "else", ":", "raise", "ValueE...
Parses a ``bool`` from the string, matching 'true' or 'false' ignoring case.
[ "Parses", "a", "bool", "from", "the", "string", "matching", "true", "or", "false", "ignoring", "case", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L686-L696
train
spotify/luigi
luigi/parameter.py
DateIntervalParameter.parse
def parse(self, s): """ Parses a :py:class:`~luigi.date_interval.DateInterval` from the input. see :py:mod:`luigi.date_interval` for details on the parsing of DateIntervals. """ # TODO: can we use xml.utils.iso8601 or something similar? from luigi import date_...
python
def parse(self, s): """ Parses a :py:class:`~luigi.date_interval.DateInterval` from the input. see :py:mod:`luigi.date_interval` for details on the parsing of DateIntervals. """ # TODO: can we use xml.utils.iso8601 or something similar? from luigi import date_...
[ "def", "parse", "(", "self", ",", "s", ")", ":", "# TODO: can we use xml.utils.iso8601 or something similar?", "from", "luigi", "import", "date_interval", "as", "d", "for", "cls", "in", "[", "d", ".", "Year", ",", "d", ".", "Month", ",", "d", ".", "Week", ...
Parses a :py:class:`~luigi.date_interval.DateInterval` from the input. see :py:mod:`luigi.date_interval` for details on the parsing of DateIntervals.
[ "Parses", "a", ":", "py", ":", "class", ":", "~luigi", ".", "date_interval", ".", "DateInterval", "from", "the", "input", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L726-L742
train
spotify/luigi
luigi/parameter.py
TimeDeltaParameter.parse
def parse(self, input): """ Parses a time delta from the input. See :py:class:`TimeDeltaParameter` for details on supported formats. """ result = self._parseIso8601(input) if not result: result = self._parseSimple(input) if result is not None: ...
python
def parse(self, input): """ Parses a time delta from the input. See :py:class:`TimeDeltaParameter` for details on supported formats. """ result = self._parseIso8601(input) if not result: result = self._parseSimple(input) if result is not None: ...
[ "def", "parse", "(", "self", ",", "input", ")", ":", "result", "=", "self", ".", "_parseIso8601", "(", "input", ")", "if", "not", "result", ":", "result", "=", "self", ".", "_parseSimple", "(", "input", ")", "if", "result", "is", "not", "None", ":", ...
Parses a time delta from the input. See :py:class:`TimeDeltaParameter` for details on supported formats.
[ "Parses", "a", "time", "delta", "from", "the", "input", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L790-L802
train
spotify/luigi
luigi/parameter.py
TimeDeltaParameter.serialize
def serialize(self, x): """ Converts datetime.timedelta to a string :param x: the value to serialize. """ weeks = x.days // 7 days = x.days % 7 hours = x.seconds // 3600 minutes = (x.seconds % 3600) // 60 seconds = (x.seconds % 3600) % 60 ...
python
def serialize(self, x): """ Converts datetime.timedelta to a string :param x: the value to serialize. """ weeks = x.days // 7 days = x.days % 7 hours = x.seconds // 3600 minutes = (x.seconds % 3600) // 60 seconds = (x.seconds % 3600) % 60 ...
[ "def", "serialize", "(", "self", ",", "x", ")", ":", "weeks", "=", "x", ".", "days", "//", "7", "days", "=", "x", ".", "days", "%", "7", "hours", "=", "x", ".", "seconds", "//", "3600", "minutes", "=", "(", "x", ".", "seconds", "%", "3600", "...
Converts datetime.timedelta to a string :param x: the value to serialize.
[ "Converts", "datetime", ".", "timedelta", "to", "a", "string" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L804-L816
train
spotify/luigi
luigi/parameter.py
TupleParameter.parse
def parse(self, x): """ Parse an individual value from the input. :param str x: the value to parse. :return: the parsed value. """ # Since the result of json.dumps(tuple) differs from a tuple string, we must handle either case. # A tuple string may come from a co...
python
def parse(self, x): """ Parse an individual value from the input. :param str x: the value to parse. :return: the parsed value. """ # Since the result of json.dumps(tuple) differs from a tuple string, we must handle either case. # A tuple string may come from a co...
[ "def", "parse", "(", "self", ",", "x", ")", ":", "# Since the result of json.dumps(tuple) differs from a tuple string, we must handle either case.", "# A tuple string may come from a config file or from cli execution.", "# t = ((1, 2), (3, 4))", "# t_str = '((1,2),(3,4))'", "# t_json_str = j...
Parse an individual value from the input. :param str x: the value to parse. :return: the parsed value.
[ "Parse", "an", "individual", "value", "from", "the", "input", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/parameter.py#L1096-L1119
train
spotify/luigi
examples/wordcount.py
WordCount.run
def run(self): """ 1. count the words for each of the :py:meth:`~.InputText.output` targets created by :py:class:`~.InputText` 2. write the count into the :py:meth:`~.WordCount.output` target """ count = {} # NOTE: self.input() actually returns an element for the InputTe...
python
def run(self): """ 1. count the words for each of the :py:meth:`~.InputText.output` targets created by :py:class:`~.InputText` 2. write the count into the :py:meth:`~.WordCount.output` target """ count = {} # NOTE: self.input() actually returns an element for the InputTe...
[ "def", "run", "(", "self", ")", ":", "count", "=", "{", "}", "# NOTE: self.input() actually returns an element for the InputText.output() target", "for", "f", "in", "self", ".", "input", "(", ")", ":", "# The input() method is a wrapper around requires() that returns Target o...
1. count the words for each of the :py:meth:`~.InputText.output` targets created by :py:class:`~.InputText` 2. write the count into the :py:meth:`~.WordCount.output` target
[ "1", ".", "count", "the", "words", "for", "each", "of", "the", ":", "py", ":", "meth", ":", "~", ".", "InputText", ".", "output", "targets", "created", "by", ":", "py", ":", "class", ":", "~", ".", "InputText", "2", ".", "write", "the", "count", ...
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/examples/wordcount.py#L63-L80
train
spotify/luigi
luigi/contrib/hadoop.py
create_packages_archive
def create_packages_archive(packages, filename): """ Create a tar archive which will contain the files for the packages listed in packages. """ import tarfile tar = tarfile.open(filename, "w") def add(src, dst): logger.debug('adding to tar: %s -> %s', src, dst) tar.add(src, dst)...
python
def create_packages_archive(packages, filename): """ Create a tar archive which will contain the files for the packages listed in packages. """ import tarfile tar = tarfile.open(filename, "w") def add(src, dst): logger.debug('adding to tar: %s -> %s', src, dst) tar.add(src, dst)...
[ "def", "create_packages_archive", "(", "packages", ",", "filename", ")", ":", "import", "tarfile", "tar", "=", "tarfile", ".", "open", "(", "filename", ",", "\"w\"", ")", "def", "add", "(", "src", ",", "dst", ")", ":", "logger", ".", "debug", "(", "'ad...
Create a tar archive which will contain the files for the packages listed in packages.
[ "Create", "a", "tar", "archive", "which", "will", "contain", "the", "files", "for", "the", "packages", "listed", "in", "packages", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L124-L194
train
spotify/luigi
luigi/contrib/hadoop.py
flatten
def flatten(sequence): """ A simple generator which flattens a sequence. Only one level is flattened. .. code-block:: python (1, (2, 3), 4) -> (1, 2, 3, 4) """ for item in sequence: if hasattr(item, "__iter__") and not isinstance(item, str) and not isinstance(item, bytes): ...
python
def flatten(sequence): """ A simple generator which flattens a sequence. Only one level is flattened. .. code-block:: python (1, (2, 3), 4) -> (1, 2, 3, 4) """ for item in sequence: if hasattr(item, "__iter__") and not isinstance(item, str) and not isinstance(item, bytes): ...
[ "def", "flatten", "(", "sequence", ")", ":", "for", "item", "in", "sequence", ":", "if", "hasattr", "(", "item", ",", "\"__iter__\"", ")", "and", "not", "isinstance", "(", "item", ",", "str", ")", "and", "not", "isinstance", "(", "item", ",", "bytes", ...
A simple generator which flattens a sequence. Only one level is flattened. .. code-block:: python (1, (2, 3), 4) -> (1, 2, 3, 4)
[ "A", "simple", "generator", "which", "flattens", "a", "sequence", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L197-L213
train
spotify/luigi
luigi/contrib/hadoop.py
run_and_track_hadoop_job
def run_and_track_hadoop_job(arglist, tracking_url_callback=None, env=None): """ Runs the job by invoking the command from the given arglist. Finds tracking urls from the output and attempts to fetch errors using those urls if the job fails. Throws HadoopJobError with information about the error (in...
python
def run_and_track_hadoop_job(arglist, tracking_url_callback=None, env=None): """ Runs the job by invoking the command from the given arglist. Finds tracking urls from the output and attempts to fetch errors using those urls if the job fails. Throws HadoopJobError with information about the error (in...
[ "def", "run_and_track_hadoop_job", "(", "arglist", ",", "tracking_url_callback", "=", "None", ",", "env", "=", "None", ")", ":", "logger", ".", "info", "(", "'%s'", ",", "subprocess", ".", "list2cmdline", "(", "arglist", ")", ")", "def", "write_luigi_history",...
Runs the job by invoking the command from the given arglist. Finds tracking urls from the output and attempts to fetch errors using those urls if the job fails. Throws HadoopJobError with information about the error (including stdout and stderr from the process) on failure and returns normally otherwise...
[ "Runs", "the", "job", "by", "invoking", "the", "command", "from", "the", "given", "arglist", ".", "Finds", "tracking", "urls", "from", "the", "output", "and", "attempts", "to", "fetch", "errors", "using", "those", "urls", "if", "the", "job", "fails", ".", ...
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L256-L353
train
spotify/luigi
luigi/contrib/hadoop.py
fetch_task_failures
def fetch_task_failures(tracking_url): """ Uses mechanize to fetch the actual task logs from the task tracker. This is highly opportunistic, and we might not succeed. So we set a low timeout and hope it works. If it does not, it's not the end of the world. TODO: Yarn has a REST API that we sho...
python
def fetch_task_failures(tracking_url): """ Uses mechanize to fetch the actual task logs from the task tracker. This is highly opportunistic, and we might not succeed. So we set a low timeout and hope it works. If it does not, it's not the end of the world. TODO: Yarn has a REST API that we sho...
[ "def", "fetch_task_failures", "(", "tracking_url", ")", ":", "import", "mechanize", "timeout", "=", "3.0", "failures_url", "=", "tracking_url", ".", "replace", "(", "'jobdetails.jsp'", ",", "'jobfailures.jsp'", ")", "+", "'&cause=failed'", "logger", ".", "debug", ...
Uses mechanize to fetch the actual task logs from the task tracker. This is highly opportunistic, and we might not succeed. So we set a low timeout and hope it works. If it does not, it's not the end of the world. TODO: Yarn has a REST API that we should probably use instead: http://hadoop.apache....
[ "Uses", "mechanize", "to", "fetch", "the", "actual", "task", "logs", "from", "the", "task", "tracker", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L356-L391
train
spotify/luigi
luigi/contrib/hadoop.py
BaseHadoopJobTask._get_pool
def _get_pool(self): """ Protected method """ if self.pool: return self.pool if hadoop().pool: return hadoop().pool
python
def _get_pool(self): """ Protected method """ if self.pool: return self.pool if hadoop().pool: return hadoop().pool
[ "def", "_get_pool", "(", "self", ")", ":", "if", "self", ".", "pool", ":", "return", "self", ".", "pool", "if", "hadoop", "(", ")", ".", "pool", ":", "return", "hadoop", "(", ")", ".", "pool" ]
Protected method
[ "Protected", "method" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L688-L693
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask.job_runner
def job_runner(self): # We recommend that you define a subclass, override this method and set up your own config """ Get the MapReduce runner for this job. If all outputs are HdfsTargets, the DefaultHadoopJobRunner will be used. Otherwise, the LocalJobRunner which streams all da...
python
def job_runner(self): # We recommend that you define a subclass, override this method and set up your own config """ Get the MapReduce runner for this job. If all outputs are HdfsTargets, the DefaultHadoopJobRunner will be used. Otherwise, the LocalJobRunner which streams all da...
[ "def", "job_runner", "(", "self", ")", ":", "# We recommend that you define a subclass, override this method and set up your own config", "outputs", "=", "luigi", ".", "task", ".", "flatten", "(", "self", ".", "output", "(", ")", ")", "for", "output", "in", "outputs",...
Get the MapReduce runner for this job. If all outputs are HdfsTargets, the DefaultHadoopJobRunner will be used. Otherwise, the LocalJobRunner which streams all data through the local machine will be used (great for testing).
[ "Get", "the", "MapReduce", "runner", "for", "this", "job", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L813-L829
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask.writer
def writer(self, outputs, stdout, stderr=sys.stderr): """ Writer format is a method which iterates over the output records from the reducer and formats them for output. The default implementation outputs tab separated items. """ for output in outputs: try: ...
python
def writer(self, outputs, stdout, stderr=sys.stderr): """ Writer format is a method which iterates over the output records from the reducer and formats them for output. The default implementation outputs tab separated items. """ for output in outputs: try: ...
[ "def", "writer", "(", "self", ",", "outputs", ",", "stdout", ",", "stderr", "=", "sys", ".", "stderr", ")", ":", "for", "output", "in", "outputs", ":", "try", ":", "output", "=", "flatten", "(", "output", ")", "if", "self", ".", "data_interchange_forma...
Writer format is a method which iterates over the output records from the reducer and formats them for output. The default implementation outputs tab separated items.
[ "Writer", "format", "is", "a", "method", "which", "iterates", "over", "the", "output", "records", "from", "the", "reducer", "and", "formats", "them", "for", "output", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L839-L858
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask.incr_counter
def incr_counter(self, *args, **kwargs): """ Increments a Hadoop counter. Since counters can be a bit slow to update, this batches the updates. """ threshold = kwargs.get("threshold", self.batch_counter_default) if len(args) == 2: # backwards compatibility wi...
python
def incr_counter(self, *args, **kwargs): """ Increments a Hadoop counter. Since counters can be a bit slow to update, this batches the updates. """ threshold = kwargs.get("threshold", self.batch_counter_default) if len(args) == 2: # backwards compatibility wi...
[ "def", "incr_counter", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "threshold", "=", "kwargs", ".", "get", "(", "\"threshold\"", ",", "self", ".", "batch_counter_default", ")", "if", "len", "(", "args", ")", "==", "2", ":", "# b...
Increments a Hadoop counter. Since counters can be a bit slow to update, this batches the updates.
[ "Increments", "a", "Hadoop", "counter", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L870-L891
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask._flush_batch_incr_counter
def _flush_batch_incr_counter(self): """ Increments any unflushed counter values. """ for key, count in six.iteritems(self._counter_dict): if count == 0: continue args = list(key) + [count] self._incr_counter(*args) self._co...
python
def _flush_batch_incr_counter(self): """ Increments any unflushed counter values. """ for key, count in six.iteritems(self._counter_dict): if count == 0: continue args = list(key) + [count] self._incr_counter(*args) self._co...
[ "def", "_flush_batch_incr_counter", "(", "self", ")", ":", "for", "key", ",", "count", "in", "six", ".", "iteritems", "(", "self", ".", "_counter_dict", ")", ":", "if", "count", "==", "0", ":", "continue", "args", "=", "list", "(", "key", ")", "+", "...
Increments any unflushed counter values.
[ "Increments", "any", "unflushed", "counter", "values", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L893-L902
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask._incr_counter
def _incr_counter(self, *args): """ Increments a Hadoop counter. Note that this seems to be a bit slow, ~1 ms Don't overuse this function by updating very frequently. """ if len(args) == 2: # backwards compatibility with existing hadoop jobs grou...
python
def _incr_counter(self, *args): """ Increments a Hadoop counter. Note that this seems to be a bit slow, ~1 ms Don't overuse this function by updating very frequently. """ if len(args) == 2: # backwards compatibility with existing hadoop jobs grou...
[ "def", "_incr_counter", "(", "self", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "2", ":", "# backwards compatibility with existing hadoop jobs", "group_name", ",", "count", "=", "args", "print", "(", "'reporter:counter:%s,%s'", "%", "(", ...
Increments a Hadoop counter. Note that this seems to be a bit slow, ~1 ms Don't overuse this function by updating very frequently.
[ "Increments", "a", "Hadoop", "counter", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L904-L918
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask.dump
def dump(self, directory=''): """ Dump instance to file. """ with self.no_unpicklable_properties(): file_name = os.path.join(directory, 'job-instance.pickle') if self.__module__ == '__main__': d = pickle.dumps(self) module_name = os...
python
def dump(self, directory=''): """ Dump instance to file. """ with self.no_unpicklable_properties(): file_name = os.path.join(directory, 'job-instance.pickle') if self.__module__ == '__main__': d = pickle.dumps(self) module_name = os...
[ "def", "dump", "(", "self", ",", "directory", "=", "''", ")", ":", "with", "self", ".", "no_unpicklable_properties", "(", ")", ":", "file_name", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "'job-instance.pickle'", ")", "if", "self", ".", ...
Dump instance to file.
[ "Dump", "instance", "to", "file", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L974-L987
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask._map_input
def _map_input(self, input_stream): """ Iterate over input and call the mapper for each item. If the job has a parser defined, the return values from the parser will be passed as arguments to the mapper. If the input is coded output from a previous run, the arguments wil...
python
def _map_input(self, input_stream): """ Iterate over input and call the mapper for each item. If the job has a parser defined, the return values from the parser will be passed as arguments to the mapper. If the input is coded output from a previous run, the arguments wil...
[ "def", "_map_input", "(", "self", ",", "input_stream", ")", ":", "for", "record", "in", "self", ".", "reader", "(", "input_stream", ")", ":", "for", "output", "in", "self", ".", "mapper", "(", "*", "record", ")", ":", "yield", "output", "if", "self", ...
Iterate over input and call the mapper for each item. If the job has a parser defined, the return values from the parser will be passed as arguments to the mapper. If the input is coded output from a previous run, the arguments will be splitted in key and value.
[ "Iterate", "over", "input", "and", "call", "the", "mapper", "for", "each", "item", ".", "If", "the", "job", "has", "a", "parser", "defined", "the", "return", "values", "from", "the", "parser", "will", "be", "passed", "as", "arguments", "to", "the", "mapp...
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L989-L1004
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask._reduce_input
def _reduce_input(self, inputs, reducer, final=NotImplemented): """ Iterate over input, collect values with the same key, and call the reducer for each unique key. """ for key, values in groupby(inputs, key=lambda x: self.internal_serialize(x[0])): for output in reducer(self....
python
def _reduce_input(self, inputs, reducer, final=NotImplemented): """ Iterate over input, collect values with the same key, and call the reducer for each unique key. """ for key, values in groupby(inputs, key=lambda x: self.internal_serialize(x[0])): for output in reducer(self....
[ "def", "_reduce_input", "(", "self", ",", "inputs", ",", "reducer", ",", "final", "=", "NotImplemented", ")", ":", "for", "key", ",", "values", "in", "groupby", "(", "inputs", ",", "key", "=", "lambda", "x", ":", "self", ".", "internal_serialize", "(", ...
Iterate over input, collect values with the same key, and call the reducer for each unique key.
[ "Iterate", "over", "input", "collect", "values", "with", "the", "same", "key", "and", "call", "the", "reducer", "for", "each", "unique", "key", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L1006-L1016
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask.run_mapper
def run_mapper(self, stdin=sys.stdin, stdout=sys.stdout): """ Run the mapper on the hadoop node. """ self.init_hadoop() self.init_mapper() outputs = self._map_input((line[:-1] for line in stdin)) if self.reducer == NotImplemented: self.writer(outputs, ...
python
def run_mapper(self, stdin=sys.stdin, stdout=sys.stdout): """ Run the mapper on the hadoop node. """ self.init_hadoop() self.init_mapper() outputs = self._map_input((line[:-1] for line in stdin)) if self.reducer == NotImplemented: self.writer(outputs, ...
[ "def", "run_mapper", "(", "self", ",", "stdin", "=", "sys", ".", "stdin", ",", "stdout", "=", "sys", ".", "stdout", ")", ":", "self", ".", "init_hadoop", "(", ")", "self", ".", "init_mapper", "(", ")", "outputs", "=", "self", ".", "_map_input", "(", ...
Run the mapper on the hadoop node.
[ "Run", "the", "mapper", "on", "the", "hadoop", "node", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L1018-L1028
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask.run_reducer
def run_reducer(self, stdin=sys.stdin, stdout=sys.stdout): """ Run the reducer on the hadoop node. """ self.init_hadoop() self.init_reducer() outputs = self._reduce_input(self.internal_reader((line[:-1] for line in stdin)), self.reducer, self.final_reducer) self.w...
python
def run_reducer(self, stdin=sys.stdin, stdout=sys.stdout): """ Run the reducer on the hadoop node. """ self.init_hadoop() self.init_reducer() outputs = self._reduce_input(self.internal_reader((line[:-1] for line in stdin)), self.reducer, self.final_reducer) self.w...
[ "def", "run_reducer", "(", "self", ",", "stdin", "=", "sys", ".", "stdin", ",", "stdout", "=", "sys", ".", "stdout", ")", ":", "self", ".", "init_hadoop", "(", ")", "self", ".", "init_reducer", "(", ")", "outputs", "=", "self", ".", "_reduce_input", ...
Run the reducer on the hadoop node.
[ "Run", "the", "reducer", "on", "the", "hadoop", "node", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L1030-L1037
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask.internal_reader
def internal_reader(self, input_stream): """ Reader which uses python eval on each part of a tab separated string. Yields a tuple of python objects. """ for input_line in input_stream: yield list(map(self.deserialize, input_line.split("\t")))
python
def internal_reader(self, input_stream): """ Reader which uses python eval on each part of a tab separated string. Yields a tuple of python objects. """ for input_line in input_stream: yield list(map(self.deserialize, input_line.split("\t")))
[ "def", "internal_reader", "(", "self", ",", "input_stream", ")", ":", "for", "input_line", "in", "input_stream", ":", "yield", "list", "(", "map", "(", "self", ".", "deserialize", ",", "input_line", ".", "split", "(", "\"\\t\"", ")", ")", ")" ]
Reader which uses python eval on each part of a tab separated string. Yields a tuple of python objects.
[ "Reader", "which", "uses", "python", "eval", "on", "each", "part", "of", "a", "tab", "separated", "string", ".", "Yields", "a", "tuple", "of", "python", "objects", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L1045-L1051
train
spotify/luigi
luigi/contrib/hadoop.py
JobTask.internal_writer
def internal_writer(self, outputs, stdout): """ Writer which outputs the python repr for each item. """ for output in outputs: print("\t".join(map(self.internal_serialize, output)), file=stdout)
python
def internal_writer(self, outputs, stdout): """ Writer which outputs the python repr for each item. """ for output in outputs: print("\t".join(map(self.internal_serialize, output)), file=stdout)
[ "def", "internal_writer", "(", "self", ",", "outputs", ",", "stdout", ")", ":", "for", "output", "in", "outputs", ":", "print", "(", "\"\\t\"", ".", "join", "(", "map", "(", "self", ".", "internal_serialize", ",", "output", ")", ")", ",", "file", "=", ...
Writer which outputs the python repr for each item.
[ "Writer", "which", "outputs", "the", "python", "repr", "for", "each", "item", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L1053-L1058
train
spotify/luigi
luigi/contrib/postgres.py
PostgresTarget.touch
def touch(self, connection=None): """ Mark this update as complete. Important: If the marker table doesn't exist, the connection transaction will be aborted and the connection reset. Then the marker table will be created. """ self.create_marker_table() i...
python
def touch(self, connection=None): """ Mark this update as complete. Important: If the marker table doesn't exist, the connection transaction will be aborted and the connection reset. Then the marker table will be created. """ self.create_marker_table() i...
[ "def", "touch", "(", "self", ",", "connection", "=", "None", ")", ":", "self", ".", "create_marker_table", "(", ")", "if", "connection", "is", "None", ":", "# TODO: test this", "connection", "=", "self", ".", "connect", "(", ")", "connection", ".", "autoco...
Mark this update as complete. Important: If the marker table doesn't exist, the connection transaction will be aborted and the connection reset. Then the marker table will be created.
[ "Mark", "this", "update", "as", "complete", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L139-L166
train
spotify/luigi
luigi/contrib/postgres.py
PostgresTarget.connect
def connect(self): """ Get a psycopg2 connection object to the database where the table is. """ connection = psycopg2.connect( host=self.host, port=self.port, database=self.database, user=self.user, password=self.password) ...
python
def connect(self): """ Get a psycopg2 connection object to the database where the table is. """ connection = psycopg2.connect( host=self.host, port=self.port, database=self.database, user=self.user, password=self.password) ...
[ "def", "connect", "(", "self", ")", ":", "connection", "=", "psycopg2", ".", "connect", "(", "host", "=", "self", ".", "host", ",", "port", "=", "self", ".", "port", ",", "database", "=", "self", ".", "database", ",", "user", "=", "self", ".", "use...
Get a psycopg2 connection object to the database where the table is.
[ "Get", "a", "psycopg2", "connection", "object", "to", "the", "database", "where", "the", "table", "is", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L187-L198
train
spotify/luigi
luigi/contrib/postgres.py
PostgresTarget.create_marker_table
def create_marker_table(self): """ Create marker table if it doesn't exist. Using a separate connection since the transaction might have to be reset. """ connection = self.connect() connection.autocommit = True cursor = connection.cursor() if self.use_db_...
python
def create_marker_table(self): """ Create marker table if it doesn't exist. Using a separate connection since the transaction might have to be reset. """ connection = self.connect() connection.autocommit = True cursor = connection.cursor() if self.use_db_...
[ "def", "create_marker_table", "(", "self", ")", ":", "connection", "=", "self", ".", "connect", "(", ")", "connection", ".", "autocommit", "=", "True", "cursor", "=", "connection", ".", "cursor", "(", ")", "if", "self", ".", "use_db_timestamps", ":", "sql"...
Create marker table if it doesn't exist. Using a separate connection since the transaction might have to be reset.
[ "Create", "marker", "table", "if", "it", "doesn", "t", "exist", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L200-L229
train
spotify/luigi
luigi/contrib/postgres.py
CopyToTable.rows
def rows(self): """ Return/yield tuples or lists corresponding to each row to be inserted. """ with self.input().open('r') as fobj: for line in fobj: yield line.strip('\n').split('\t')
python
def rows(self): """ Return/yield tuples or lists corresponding to each row to be inserted. """ with self.input().open('r') as fobj: for line in fobj: yield line.strip('\n').split('\t')
[ "def", "rows", "(", "self", ")", ":", "with", "self", ".", "input", "(", ")", ".", "open", "(", "'r'", ")", "as", "fobj", ":", "for", "line", "in", "fobj", ":", "yield", "line", ".", "strip", "(", "'\\n'", ")", ".", "split", "(", "'\\t'", ")" ]
Return/yield tuples or lists corresponding to each row to be inserted.
[ "Return", "/", "yield", "tuples", "or", "lists", "corresponding", "to", "each", "row", "to", "be", "inserted", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L247-L253
train
spotify/luigi
luigi/contrib/postgres.py
CopyToTable.map_column
def map_column(self, value): """ Applied to each column of every row returned by `rows`. Default behaviour is to escape special characters and identify any self.null_values. """ if value in self.null_values: return r'\\N' else: return default_esca...
python
def map_column(self, value): """ Applied to each column of every row returned by `rows`. Default behaviour is to escape special characters and identify any self.null_values. """ if value in self.null_values: return r'\\N' else: return default_esca...
[ "def", "map_column", "(", "self", ",", "value", ")", ":", "if", "value", "in", "self", ".", "null_values", ":", "return", "r'\\\\N'", "else", ":", "return", "default_escape", "(", "six", ".", "text_type", "(", "value", ")", ")" ]
Applied to each column of every row returned by `rows`. Default behaviour is to escape special characters and identify any self.null_values.
[ "Applied", "to", "each", "column", "of", "every", "row", "returned", "by", "rows", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L255-L264
train
spotify/luigi
luigi/contrib/postgres.py
CopyToTable.output
def output(self): """ Returns a PostgresTarget representing the inserted dataset. Normally you don't override this. """ return PostgresTarget( host=self.host, database=self.database, user=self.user, password=self.password, ...
python
def output(self): """ Returns a PostgresTarget representing the inserted dataset. Normally you don't override this. """ return PostgresTarget( host=self.host, database=self.database, user=self.user, password=self.password, ...
[ "def", "output", "(", "self", ")", ":", "return", "PostgresTarget", "(", "host", "=", "self", ".", "host", ",", "database", "=", "self", ".", "database", ",", "user", "=", "self", ".", "user", ",", "password", "=", "self", ".", "password", ",", "tabl...
Returns a PostgresTarget representing the inserted dataset. Normally you don't override this.
[ "Returns", "a", "PostgresTarget", "representing", "the", "inserted", "dataset", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L268-L282
train
spotify/luigi
luigi/contrib/postgres.py
CopyToTable.run
def run(self): """ Inserts data generated by rows() into target table. If the target table doesn't exist, self.create_table will be called to attempt to create the table. Normally you don't want to override this. """ if not (self.table and self.columns): rai...
python
def run(self): """ Inserts data generated by rows() into target table. If the target table doesn't exist, self.create_table will be called to attempt to create the table. Normally you don't want to override this. """ if not (self.table and self.columns): rai...
[ "def", "run", "(", "self", ")", ":", "if", "not", "(", "self", ".", "table", "and", "self", ".", "columns", ")", ":", "raise", "Exception", "(", "\"table and columns need to be specified\"", ")", "connection", "=", "self", ".", "output", "(", ")", ".", "...
Inserts data generated by rows() into target table. If the target table doesn't exist, self.create_table will be called to attempt to create the table. Normally you don't want to override this.
[ "Inserts", "data", "generated", "by", "rows", "()", "into", "target", "table", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/postgres.py#L293-L349
train
spotify/luigi
luigi/configuration/core.py
get_config
def get_config(parser=PARSER): """Get configs singleton for parser """ parser_class = PARSERS[parser] _check_parser(parser_class, parser) return parser_class.instance()
python
def get_config(parser=PARSER): """Get configs singleton for parser """ parser_class = PARSERS[parser] _check_parser(parser_class, parser) return parser_class.instance()
[ "def", "get_config", "(", "parser", "=", "PARSER", ")", ":", "parser_class", "=", "PARSERS", "[", "parser", "]", "_check_parser", "(", "parser_class", ",", "parser", ")", "return", "parser_class", ".", "instance", "(", ")" ]
Get configs singleton for parser
[ "Get", "configs", "singleton", "for", "parser" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/configuration/core.py#L53-L58
train
spotify/luigi
luigi/configuration/core.py
add_config_path
def add_config_path(path): """Select config parser by file extension and add path into parser. """ if not os.path.isfile(path): warnings.warn("Config file does not exist: {path}".format(path=path)) return False # select parser by file extension _base, ext = os.path.splitext(path) ...
python
def add_config_path(path): """Select config parser by file extension and add path into parser. """ if not os.path.isfile(path): warnings.warn("Config file does not exist: {path}".format(path=path)) return False # select parser by file extension _base, ext = os.path.splitext(path) ...
[ "def", "add_config_path", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "warnings", ".", "warn", "(", "\"Config file does not exist: {path}\"", ".", "format", "(", "path", "=", "path", ")", ")", "return", "F...
Select config parser by file extension and add path into parser.
[ "Select", "config", "parser", "by", "file", "extension", "and", "add", "path", "into", "parser", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/configuration/core.py#L61-L87
train
spotify/luigi
luigi/contrib/spark.py
PySparkTask._setup_packages
def _setup_packages(self, sc): """ This method compresses and uploads packages to the cluster """ packages = self.py_packages if not packages: return for package in packages: mod = importlib.import_module(package) try: ...
python
def _setup_packages(self, sc): """ This method compresses and uploads packages to the cluster """ packages = self.py_packages if not packages: return for package in packages: mod = importlib.import_module(package) try: ...
[ "def", "_setup_packages", "(", "self", ",", "sc", ")", ":", "packages", "=", "self", ".", "py_packages", "if", "not", "packages", ":", "return", "for", "package", "in", "packages", ":", "mod", "=", "importlib", ".", "import_module", "(", "package", ")", ...
This method compresses and uploads packages to the cluster
[ "This", "method", "compresses", "and", "uploads", "packages", "to", "the", "cluster" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/spark.py#L323-L341
train
spotify/luigi
luigi/contrib/mrrunner.py
main
def main(args=None, stdin=sys.stdin, stdout=sys.stdout, print_exception=print_exception): """ Run either the mapper, combiner, or reducer from the class instance in the file "job-instance.pickle". Arguments: kind -- is either map, combiner, or reduce """ try: # Set up logging. ...
python
def main(args=None, stdin=sys.stdin, stdout=sys.stdout, print_exception=print_exception): """ Run either the mapper, combiner, or reducer from the class instance in the file "job-instance.pickle". Arguments: kind -- is either map, combiner, or reduce """ try: # Set up logging. ...
[ "def", "main", "(", "args", "=", "None", ",", "stdin", "=", "sys", ".", "stdin", ",", "stdout", "=", "sys", ".", "stdout", ",", "print_exception", "=", "print_exception", ")", ":", "try", ":", "# Set up logging.", "logging", ".", "basicConfig", "(", "lev...
Run either the mapper, combiner, or reducer from the class instance in the file "job-instance.pickle". Arguments: kind -- is either map, combiner, or reduce
[ "Run", "either", "the", "mapper", "combiner", "or", "reducer", "from", "the", "class", "instance", "in", "the", "file", "job", "-", "instance", ".", "pickle", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/mrrunner.py#L80-L97
train
spotify/luigi
luigi/retcodes.py
run_with_retcodes
def run_with_retcodes(argv): """ Run luigi with command line parsing, but raise ``SystemExit`` with the configured exit code. Note: Usually you use the luigi binary directly and don't call this function yourself. :param argv: Should (conceptually) be ``sys.argv[1:]`` """ logger = logging.getLo...
python
def run_with_retcodes(argv): """ Run luigi with command line parsing, but raise ``SystemExit`` with the configured exit code. Note: Usually you use the luigi binary directly and don't call this function yourself. :param argv: Should (conceptually) be ``sys.argv[1:]`` """ logger = logging.getLo...
[ "def", "run_with_retcodes", "(", "argv", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "'luigi-interface'", ")", "with", "luigi", ".", "cmdline_parser", ".", "CmdlineParser", ".", "global_instance", "(", "argv", ")", ":", "retcodes", "=", "retcode...
Run luigi with command line parsing, but raise ``SystemExit`` with the configured exit code. Note: Usually you use the luigi binary directly and don't call this function yourself. :param argv: Should (conceptually) be ``sys.argv[1:]``
[ "Run", "luigi", "with", "command", "line", "parsing", "but", "raise", "SystemExit", "with", "the", "configured", "exit", "code", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/retcodes.py#L61-L108
train
spotify/luigi
luigi/tools/deps.py
find_deps_cli
def find_deps_cli(): ''' Finds all tasks on all paths from provided CLI task ''' cmdline_args = sys.argv[1:] with CmdlineParser.global_instance(cmdline_args) as cp: return find_deps(cp.get_task_obj(), upstream().family)
python
def find_deps_cli(): ''' Finds all tasks on all paths from provided CLI task ''' cmdline_args = sys.argv[1:] with CmdlineParser.global_instance(cmdline_args) as cp: return find_deps(cp.get_task_obj(), upstream().family)
[ "def", "find_deps_cli", "(", ")", ":", "cmdline_args", "=", "sys", ".", "argv", "[", "1", ":", "]", "with", "CmdlineParser", ".", "global_instance", "(", "cmdline_args", ")", "as", "cp", ":", "return", "find_deps", "(", "cp", ".", "get_task_obj", "(", ")...
Finds all tasks on all paths from provided CLI task
[ "Finds", "all", "tasks", "on", "all", "paths", "from", "provided", "CLI", "task" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/deps.py#L85-L91
train
spotify/luigi
luigi/tools/deps.py
get_task_output_description
def get_task_output_description(task_output): ''' Returns a task's output as a string ''' output_description = "n/a" if isinstance(task_output, RemoteTarget): output_description = "[SSH] {0}:{1}".format(task_output._fs.remote_context.host, task_output.path) elif isinstance(task_output, ...
python
def get_task_output_description(task_output): ''' Returns a task's output as a string ''' output_description = "n/a" if isinstance(task_output, RemoteTarget): output_description = "[SSH] {0}:{1}".format(task_output._fs.remote_context.host, task_output.path) elif isinstance(task_output, ...
[ "def", "get_task_output_description", "(", "task_output", ")", ":", "output_description", "=", "\"n/a\"", "if", "isinstance", "(", "task_output", ",", "RemoteTarget", ")", ":", "output_description", "=", "\"[SSH] {0}:{1}\"", ".", "format", "(", "task_output", ".", "...
Returns a task's output as a string
[ "Returns", "a", "task", "s", "output", "as", "a", "string" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/deps.py#L94-L111
train
spotify/luigi
luigi/tools/range.py
_constrain_glob
def _constrain_glob(glob, paths, limit=5): """ Tweaks glob into a list of more specific globs that together still cover paths and not too much extra. Saves us minutes long listings for long dataset histories. Specifically, in this implementation the leftmost occurrences of "[0-9]" give rise to a f...
python
def _constrain_glob(glob, paths, limit=5): """ Tweaks glob into a list of more specific globs that together still cover paths and not too much extra. Saves us minutes long listings for long dataset histories. Specifically, in this implementation the leftmost occurrences of "[0-9]" give rise to a f...
[ "def", "_constrain_glob", "(", "glob", ",", "paths", ",", "limit", "=", "5", ")", ":", "def", "digit_set_wildcard", "(", "chars", ")", ":", "\"\"\"\n Makes a wildcard expression for the set, a bit readable, e.g. [1-5].\n \"\"\"", "chars", "=", "sorted", "(",...
Tweaks glob into a list of more specific globs that together still cover paths and not too much extra. Saves us minutes long listings for long dataset histories. Specifically, in this implementation the leftmost occurrences of "[0-9]" give rise to a few separate globs that each specialize the expression t...
[ "Tweaks", "glob", "into", "a", "list", "of", "more", "specific", "globs", "that", "together", "still", "cover", "paths", "and", "not", "too", "much", "extra", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L491-L528
train
spotify/luigi
luigi/tools/range.py
most_common
def most_common(items): """ Wanted functionality from Counters (new in Python 2.7). """ counts = {} for i in items: counts.setdefault(i, 0) counts[i] += 1 return max(six.iteritems(counts), key=operator.itemgetter(1))
python
def most_common(items): """ Wanted functionality from Counters (new in Python 2.7). """ counts = {} for i in items: counts.setdefault(i, 0) counts[i] += 1 return max(six.iteritems(counts), key=operator.itemgetter(1))
[ "def", "most_common", "(", "items", ")", ":", "counts", "=", "{", "}", "for", "i", "in", "items", ":", "counts", ".", "setdefault", "(", "i", ",", "0", ")", "counts", "[", "i", "]", "+=", "1", "return", "max", "(", "six", ".", "iteritems", "(", ...
Wanted functionality from Counters (new in Python 2.7).
[ "Wanted", "functionality", "from", "Counters", "(", "new", "in", "Python", "2", ".", "7", ")", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L531-L539
train
spotify/luigi
luigi/tools/range.py
_get_per_location_glob
def _get_per_location_glob(tasks, outputs, regexes): """ Builds a glob listing existing output paths. Esoteric reverse engineering, but worth it given that (compared to an equivalent contiguousness guarantee by naive complete() checks) requests to the filesystem are cut by orders of magnitude, and ...
python
def _get_per_location_glob(tasks, outputs, regexes): """ Builds a glob listing existing output paths. Esoteric reverse engineering, but worth it given that (compared to an equivalent contiguousness guarantee by naive complete() checks) requests to the filesystem are cut by orders of magnitude, and ...
[ "def", "_get_per_location_glob", "(", "tasks", ",", "outputs", ",", "regexes", ")", ":", "paths", "=", "[", "o", ".", "path", "for", "o", "in", "outputs", "]", "# naive, because some matches could be confused by numbers earlier", "# in path, e.g. /foo/fifa2000k/bar/2000-1...
Builds a glob listing existing output paths. Esoteric reverse engineering, but worth it given that (compared to an equivalent contiguousness guarantee by naive complete() checks) requests to the filesystem are cut by orders of magnitude, and users don't even have to retrofit existing tasks anyhow.
[ "Builds", "a", "glob", "listing", "existing", "output", "paths", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L542-L570
train
spotify/luigi
luigi/tools/range.py
_get_filesystems_and_globs
def _get_filesystems_and_globs(datetime_to_task, datetime_to_re): """ Yields a (filesystem, glob) tuple per every output location of task. The task can have one or several FileSystemTarget outputs. For convenience, the task can be a luigi.WrapperTask, in which case outputs of all its dependencies ...
python
def _get_filesystems_and_globs(datetime_to_task, datetime_to_re): """ Yields a (filesystem, glob) tuple per every output location of task. The task can have one or several FileSystemTarget outputs. For convenience, the task can be a luigi.WrapperTask, in which case outputs of all its dependencies ...
[ "def", "_get_filesystems_and_globs", "(", "datetime_to_task", ",", "datetime_to_re", ")", ":", "# probe some scattered datetimes unlikely to all occur in paths, other than by being sincere datetime parameter's representations", "# TODO limit to [self.start, self.stop) so messages are less confusin...
Yields a (filesystem, glob) tuple per every output location of task. The task can have one or several FileSystemTarget outputs. For convenience, the task can be a luigi.WrapperTask, in which case outputs of all its dependencies are considered.
[ "Yields", "a", "(", "filesystem", "glob", ")", "tuple", "per", "every", "output", "location", "of", "task", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L573-L600
train
spotify/luigi
luigi/tools/range.py
_list_existing
def _list_existing(filesystem, glob, paths): """ Get all the paths that do in fact exist. Returns a set of all existing paths. Takes a luigi.target.FileSystem object, a str which represents a glob and a list of strings representing paths. """ globs = _constrain_glob(glob, paths) time_start ...
python
def _list_existing(filesystem, glob, paths): """ Get all the paths that do in fact exist. Returns a set of all existing paths. Takes a luigi.target.FileSystem object, a str which represents a glob and a list of strings representing paths. """ globs = _constrain_glob(glob, paths) time_start ...
[ "def", "_list_existing", "(", "filesystem", ",", "glob", ",", "paths", ")", ":", "globs", "=", "_constrain_glob", "(", "glob", ",", "paths", ")", "time_start", "=", "time", ".", "time", "(", ")", "listing", "=", "[", "]", "for", "g", "in", "sorted", ...
Get all the paths that do in fact exist. Returns a set of all existing paths. Takes a luigi.target.FileSystem object, a str which represents a glob and a list of strings representing paths.
[ "Get", "all", "the", "paths", "that", "do", "in", "fact", "exist", ".", "Returns", "a", "set", "of", "all", "existing", "paths", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L603-L619
train
spotify/luigi
luigi/tools/range.py
infer_bulk_complete_from_fs
def infer_bulk_complete_from_fs(datetimes, datetime_to_task, datetime_to_re): """ Efficiently determines missing datetimes by filesystem listing. The current implementation works for the common case of a task writing output to a ``FileSystemTarget`` whose path is built using strftime with format li...
python
def infer_bulk_complete_from_fs(datetimes, datetime_to_task, datetime_to_re): """ Efficiently determines missing datetimes by filesystem listing. The current implementation works for the common case of a task writing output to a ``FileSystemTarget`` whose path is built using strftime with format li...
[ "def", "infer_bulk_complete_from_fs", "(", "datetimes", ",", "datetime_to_task", ",", "datetime_to_re", ")", ":", "filesystems_and_globs_by_location", "=", "_get_filesystems_and_globs", "(", "datetime_to_task", ",", "datetime_to_re", ")", "paths_by_datetime", "=", "[", "[",...
Efficiently determines missing datetimes by filesystem listing. The current implementation works for the common case of a task writing output to a ``FileSystemTarget`` whose path is built using strftime with format like '...%Y...%m...%d...%H...', without custom ``complete()`` or ``exists()``. (Eve...
[ "Efficiently", "determines", "missing", "datetimes", "by", "filesystem", "listing", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L622-L647
train
spotify/luigi
luigi/tools/range.py
RangeBase.of_cls
def of_cls(self): """ DONT USE. Will be deleted soon. Use ``self.of``! """ if isinstance(self.of, six.string_types): warnings.warn('When using Range programatically, dont pass "of" param as string!') return Register.get_task_cls(self.of) return self.of
python
def of_cls(self): """ DONT USE. Will be deleted soon. Use ``self.of``! """ if isinstance(self.of, six.string_types): warnings.warn('When using Range programatically, dont pass "of" param as string!') return Register.get_task_cls(self.of) return self.of
[ "def", "of_cls", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "of", ",", "six", ".", "string_types", ")", ":", "warnings", ".", "warn", "(", "'When using Range programatically, dont pass \"of\" param as string!'", ")", "return", "Register", ".", ...
DONT USE. Will be deleted soon. Use ``self.of``!
[ "DONT", "USE", ".", "Will", "be", "deleted", "soon", ".", "Use", "self", ".", "of", "!" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L117-L124
train
spotify/luigi
luigi/tools/range.py
RangeBase._emit_metrics
def _emit_metrics(self, missing_datetimes, finite_start, finite_stop): """ For consistent metrics one should consider the entire range, but it is open (infinite) if stop or start is None. Hence make do with metrics respective to the finite simplification. """ datetimes =...
python
def _emit_metrics(self, missing_datetimes, finite_start, finite_stop): """ For consistent metrics one should consider the entire range, but it is open (infinite) if stop or start is None. Hence make do with metrics respective to the finite simplification. """ datetimes =...
[ "def", "_emit_metrics", "(", "self", ",", "missing_datetimes", ",", "finite_start", ",", "finite_stop", ")", ":", "datetimes", "=", "self", ".", "finite_datetimes", "(", "finite_start", "if", "self", ".", "start", "is", "None", "else", "min", "(", "finite_star...
For consistent metrics one should consider the entire range, but it is open (infinite) if stop or start is None. Hence make do with metrics respective to the finite simplification.
[ "For", "consistent", "metrics", "one", "should", "consider", "the", "entire", "range", "but", "it", "is", "open", "(", "infinite", ")", "if", "stop", "or", "start", "is", "None", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L166-L183
train
spotify/luigi
luigi/tools/range.py
RangeBase.missing_datetimes
def missing_datetimes(self, finite_datetimes): """ Override in subclasses to do bulk checks. Returns a sorted list. This is a conservative base implementation that brutally checks completeness, instance by instance. Inadvisable as it may be slow. """ return [d ...
python
def missing_datetimes(self, finite_datetimes): """ Override in subclasses to do bulk checks. Returns a sorted list. This is a conservative base implementation that brutally checks completeness, instance by instance. Inadvisable as it may be slow. """ return [d ...
[ "def", "missing_datetimes", "(", "self", ",", "finite_datetimes", ")", ":", "return", "[", "d", "for", "d", "in", "finite_datetimes", "if", "not", "self", ".", "_instantiate_task_cls", "(", "self", ".", "datetime_to_parameter", "(", "d", ")", ")", ".", "comp...
Override in subclasses to do bulk checks. Returns a sorted list. This is a conservative base implementation that brutally checks completeness, instance by instance. Inadvisable as it may be slow.
[ "Override", "in", "subclasses", "to", "do", "bulk", "checks", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L255-L265
train
spotify/luigi
luigi/tools/range.py
RangeBase._missing_datetimes
def _missing_datetimes(self, finite_datetimes): """ Backward compatible wrapper. Will be deleted eventually (stated on Dec 2015) """ try: return self.missing_datetimes(finite_datetimes) except TypeError as ex: if 'missing_datetimes()' in repr(ex): ...
python
def _missing_datetimes(self, finite_datetimes): """ Backward compatible wrapper. Will be deleted eventually (stated on Dec 2015) """ try: return self.missing_datetimes(finite_datetimes) except TypeError as ex: if 'missing_datetimes()' in repr(ex): ...
[ "def", "_missing_datetimes", "(", "self", ",", "finite_datetimes", ")", ":", "try", ":", "return", "self", ".", "missing_datetimes", "(", "finite_datetimes", ")", "except", "TypeError", "as", "ex", ":", "if", "'missing_datetimes()'", "in", "repr", "(", "ex", "...
Backward compatible wrapper. Will be deleted eventually (stated on Dec 2015)
[ "Backward", "compatible", "wrapper", ".", "Will", "be", "deleted", "eventually", "(", "stated", "on", "Dec", "2015", ")" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L267-L278
train
spotify/luigi
luigi/tools/range.py
RangeDailyBase.parameters_to_datetime
def parameters_to_datetime(self, p): """ Given a dictionary of parameters, will extract the ranged task parameter value """ dt = p[self._param_name] return datetime(dt.year, dt.month, dt.day)
python
def parameters_to_datetime(self, p): """ Given a dictionary of parameters, will extract the ranged task parameter value """ dt = p[self._param_name] return datetime(dt.year, dt.month, dt.day)
[ "def", "parameters_to_datetime", "(", "self", ",", "p", ")", ":", "dt", "=", "p", "[", "self", ".", "_param_name", "]", "return", "datetime", "(", "dt", ".", "year", ",", "dt", ".", "month", ",", "dt", ".", "day", ")" ]
Given a dictionary of parameters, will extract the ranged task parameter value
[ "Given", "a", "dictionary", "of", "parameters", "will", "extract", "the", "ranged", "task", "parameter", "value" ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L316-L321
train
spotify/luigi
luigi/tools/range.py
RangeDailyBase.finite_datetimes
def finite_datetimes(self, finite_start, finite_stop): """ Simply returns the points in time that correspond to turn of day. """ date_start = datetime(finite_start.year, finite_start.month, finite_start.day) dates = [] for i in itertools.count(): t = date_star...
python
def finite_datetimes(self, finite_start, finite_stop): """ Simply returns the points in time that correspond to turn of day. """ date_start = datetime(finite_start.year, finite_start.month, finite_start.day) dates = [] for i in itertools.count(): t = date_star...
[ "def", "finite_datetimes", "(", "self", ",", "finite_start", ",", "finite_stop", ")", ":", "date_start", "=", "datetime", "(", "finite_start", ".", "year", ",", "finite_start", ".", "month", ",", "finite_start", ".", "day", ")", "dates", "=", "[", "]", "fo...
Simply returns the points in time that correspond to turn of day.
[ "Simply", "returns", "the", "points", "in", "time", "that", "correspond", "to", "turn", "of", "day", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L329-L340
train
spotify/luigi
luigi/tools/range.py
RangeHourlyBase.finite_datetimes
def finite_datetimes(self, finite_start, finite_stop): """ Simply returns the points in time that correspond to whole hours. """ datehour_start = datetime(finite_start.year, finite_start.month, finite_start.day, finite_start.hour) datehours = [] for i in itertools.count()...
python
def finite_datetimes(self, finite_start, finite_stop): """ Simply returns the points in time that correspond to whole hours. """ datehour_start = datetime(finite_start.year, finite_start.month, finite_start.day, finite_start.hour) datehours = [] for i in itertools.count()...
[ "def", "finite_datetimes", "(", "self", ",", "finite_start", ",", "finite_stop", ")", ":", "datehour_start", "=", "datetime", "(", "finite_start", ".", "year", ",", "finite_start", ".", "month", ",", "finite_start", ".", "day", ",", "finite_start", ".", "hour"...
Simply returns the points in time that correspond to whole hours.
[ "Simply", "returns", "the", "points", "in", "time", "that", "correspond", "to", "whole", "hours", "." ]
c5eca1c3c3ee2a7eb612486192a0da146710a1e9
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/range.py#L391-L402
train