partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | main | Run the work() method from the class instance in the file "job-instance.pickle". | luigi/contrib/sge_runner.py | def main(args=sys.argv):
"""Run the work() method from the class instance in the file "job-instance.pickle".
"""
try:
tarball = "--no-tarball" not in args
# Set up logging.
logging.basicConfig(level=logging.WARN)
work_dir = args[1]
assert os.path.exists(work_dir), "Fi... | def main(args=sys.argv):
"""Run the work() method from the class instance in the file "job-instance.pickle".
"""
try:
tarball = "--no-tarball" not in args
# Set up logging.
logging.basicConfig(level=logging.WARN)
work_dir = args[1]
assert os.path.exists(work_dir), "Fi... | [
"Run",
"the",
"work",
"()",
"method",
"from",
"the",
"class",
"instance",
"in",
"the",
"file",
"job",
"-",
"instance",
".",
"pickle",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/sge_runner.py#L80-L95 | [
"def",
"main",
"(",
"args",
"=",
"sys",
".",
"argv",
")",
":",
"try",
":",
"tarball",
"=",
"\"--no-tarball\"",
"not",
"in",
"args",
"# Set up logging.",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"WARN",
")",
"work_dir",
"=",
"args... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryLoadAvro._get_input_schema | Arbitrarily picks an object in input and reads the Avro schema from it. | luigi/contrib/bigquery_avro.py | def _get_input_schema(self):
"""Arbitrarily picks an object in input and reads the Avro schema from it."""
assert avro, 'avro module required'
input_target = flatten(self.input())[0]
input_fs = input_target.fs if hasattr(input_target, 'fs') else GCSClient()
input_uri = self.sour... | def _get_input_schema(self):
"""Arbitrarily picks an object in input and reads the Avro schema from it."""
assert avro, 'avro module required'
input_target = flatten(self.input())[0]
input_fs = input_target.fs if hasattr(input_target, 'fs') else GCSClient()
input_uri = self.sour... | [
"Arbitrarily",
"picks",
"an",
"object",
"in",
"input",
"and",
"reads",
"the",
"Avro",
"schema",
"from",
"it",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery_avro.py#L40-L75 | [
"def",
"_get_input_schema",
"(",
"self",
")",
":",
"assert",
"avro",
",",
"'avro module required'",
"input_target",
"=",
"flatten",
"(",
"self",
".",
"input",
"(",
")",
")",
"[",
"0",
"]",
"input_fs",
"=",
"input_target",
".",
"fs",
"if",
"hasattr",
"(",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | print_tree | Return a string representation of the tasks, their statuses/parameters in a dependency tree format | luigi/tools/deps_tree.py | def print_tree(task, indent='', last=True):
'''
Return a string representation of the tasks, their statuses/parameters in a dependency tree format
'''
# dont bother printing out warnings about tasks with no output
with warnings.catch_warnings():
warnings.filterwarnings(action='ignore', messa... | def print_tree(task, indent='', last=True):
'''
Return a string representation of the tasks, their statuses/parameters in a dependency tree format
'''
# dont bother printing out warnings about tasks with no output
with warnings.catch_warnings():
warnings.filterwarnings(action='ignore', messa... | [
"Return",
"a",
"string",
"representation",
"of",
"the",
"tasks",
"their",
"statuses",
"/",
"parameters",
"in",
"a",
"dependency",
"tree",
"format"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/tools/deps_tree.py#L41-L63 | [
"def",
"print_tree",
"(",
"task",
",",
"indent",
"=",
"''",
",",
"last",
"=",
"True",
")",
":",
"# dont bother printing out warnings about tasks with no output",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"filterwarnings",
"(",
"act... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _urljoin | Join relative URLs to base URLs like urllib.parse.urljoin but support
arbitrary URIs (esp. 'http+unix://'). | luigi/rpc.py | def _urljoin(base, url):
"""
Join relative URLs to base URLs like urllib.parse.urljoin but support
arbitrary URIs (esp. 'http+unix://').
"""
parsed = urlparse(base)
scheme = parsed.scheme
return urlparse(
urljoin(parsed._replace(scheme='http').geturl(), url)
)._replace(scheme=sch... | def _urljoin(base, url):
"""
Join relative URLs to base URLs like urllib.parse.urljoin but support
arbitrary URIs (esp. 'http+unix://').
"""
parsed = urlparse(base)
scheme = parsed.scheme
return urlparse(
urljoin(parsed._replace(scheme='http').geturl(), url)
)._replace(scheme=sch... | [
"Join",
"relative",
"URLs",
"to",
"base",
"URLs",
"like",
"urllib",
".",
"parse",
".",
"urljoin",
"but",
"support",
"arbitrary",
"URIs",
"(",
"esp",
".",
"http",
"+",
"unix",
":",
"//",
")",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/rpc.py#L52-L61 | [
"def",
"_urljoin",
"(",
"base",
",",
"url",
")",
":",
"parsed",
"=",
"urlparse",
"(",
"base",
")",
"scheme",
"=",
"parsed",
".",
"scheme",
"return",
"urlparse",
"(",
"urljoin",
"(",
"parsed",
".",
"_replace",
"(",
"scheme",
"=",
"'http'",
")",
".",
"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.dataset_exists | Returns whether the given dataset exists.
If regional location is specified for the dataset, that is also checked
to be compatible with the remote dataset, otherwise an exception is thrown.
:param dataset:
:type dataset: BQDataset | luigi/contrib/bigquery.py | def dataset_exists(self, dataset):
"""Returns whether the given dataset exists.
If regional location is specified for the dataset, that is also checked
to be compatible with the remote dataset, otherwise an exception is thrown.
:param dataset:
:type dataset: BQDataset
... | def dataset_exists(self, dataset):
"""Returns whether the given dataset exists.
If regional location is specified for the dataset, that is also checked
to be compatible with the remote dataset, otherwise an exception is thrown.
:param dataset:
:type dataset: BQDataset
... | [
"Returns",
"whether",
"the",
"given",
"dataset",
"exists",
".",
"If",
"regional",
"location",
"is",
"specified",
"for",
"the",
"dataset",
"that",
"is",
"also",
"checked",
"to",
"be",
"compatible",
"with",
"the",
"remote",
"dataset",
"otherwise",
"an",
"excepti... | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L131-L155 | [
"def",
"dataset_exists",
"(",
"self",
",",
"dataset",
")",
":",
"try",
":",
"response",
"=",
"self",
".",
"client",
".",
"datasets",
"(",
")",
".",
"get",
"(",
"projectId",
"=",
"dataset",
".",
"project_id",
",",
"datasetId",
"=",
"dataset",
".",
"data... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.table_exists | Returns whether the given table exists.
:param table:
:type table: BQTable | luigi/contrib/bigquery.py | def table_exists(self, table):
"""Returns whether the given table exists.
:param table:
:type table: BQTable
"""
if not self.dataset_exists(table.dataset):
return False
try:
self.client.tables().get(projectId=table.project_id,
... | def table_exists(self, table):
"""Returns whether the given table exists.
:param table:
:type table: BQTable
"""
if not self.dataset_exists(table.dataset):
return False
try:
self.client.tables().get(projectId=table.project_id,
... | [
"Returns",
"whether",
"the",
"given",
"table",
"exists",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L157-L175 | [
"def",
"table_exists",
"(",
"self",
",",
"table",
")",
":",
"if",
"not",
"self",
".",
"dataset_exists",
"(",
"table",
".",
"dataset",
")",
":",
"return",
"False",
"try",
":",
"self",
".",
"client",
".",
"tables",
"(",
")",
".",
"get",
"(",
"projectId... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.make_dataset | Creates a new dataset with the default permissions.
:param dataset:
:type dataset: BQDataset
:param raise_if_exists: whether to raise an exception if the dataset already exists.
:raises luigi.target.FileAlreadyExists: if raise_if_exists=True and the dataset exists | luigi/contrib/bigquery.py | def make_dataset(self, dataset, raise_if_exists=False, body=None):
"""Creates a new dataset with the default permissions.
:param dataset:
:type dataset: BQDataset
:param raise_if_exists: whether to raise an exception if the dataset already exists.
:raises luigi.targe... | def make_dataset(self, dataset, raise_if_exists=False, body=None):
"""Creates a new dataset with the default permissions.
:param dataset:
:type dataset: BQDataset
:param raise_if_exists: whether to raise an exception if the dataset already exists.
:raises luigi.targe... | [
"Creates",
"a",
"new",
"dataset",
"with",
"the",
"default",
"permissions",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L177-L204 | [
"def",
"make_dataset",
"(",
"self",
",",
"dataset",
",",
"raise_if_exists",
"=",
"False",
",",
"body",
"=",
"None",
")",
":",
"if",
"body",
"is",
"None",
":",
"body",
"=",
"{",
"}",
"try",
":",
"# Construct a message body in the format required by",
"# https:/... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.delete_dataset | Deletes a dataset (and optionally any tables in it), if it exists.
:param dataset:
:type dataset: BQDataset
:param delete_nonempty: if true, will delete any tables before deleting the dataset | luigi/contrib/bigquery.py | def delete_dataset(self, dataset, delete_nonempty=True):
"""Deletes a dataset (and optionally any tables in it), if it exists.
:param dataset:
:type dataset: BQDataset
:param delete_nonempty: if true, will delete any tables before deleting the dataset
"""
if no... | def delete_dataset(self, dataset, delete_nonempty=True):
"""Deletes a dataset (and optionally any tables in it), if it exists.
:param dataset:
:type dataset: BQDataset
:param delete_nonempty: if true, will delete any tables before deleting the dataset
"""
if no... | [
"Deletes",
"a",
"dataset",
"(",
"and",
"optionally",
"any",
"tables",
"in",
"it",
")",
"if",
"it",
"exists",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L206-L219 | [
"def",
"delete_dataset",
"(",
"self",
",",
"dataset",
",",
"delete_nonempty",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"dataset_exists",
"(",
"dataset",
")",
":",
"return",
"self",
".",
"client",
".",
"datasets",
"(",
")",
".",
"delete",
"(",
"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.delete_table | Deletes a table, if it exists.
:param table:
:type table: BQTable | luigi/contrib/bigquery.py | def delete_table(self, table):
"""Deletes a table, if it exists.
:param table:
:type table: BQTable
"""
if not self.table_exists(table):
return
self.client.tables().delete(projectId=table.project_id,
datasetId=table... | def delete_table(self, table):
"""Deletes a table, if it exists.
:param table:
:type table: BQTable
"""
if not self.table_exists(table):
return
self.client.tables().delete(projectId=table.project_id,
datasetId=table... | [
"Deletes",
"a",
"table",
"if",
"it",
"exists",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L221-L233 | [
"def",
"delete_table",
"(",
"self",
",",
"table",
")",
":",
"if",
"not",
"self",
".",
"table_exists",
"(",
"table",
")",
":",
"return",
"self",
".",
"client",
".",
"tables",
"(",
")",
".",
"delete",
"(",
"projectId",
"=",
"table",
".",
"project_id",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.list_datasets | Returns the list of datasets in a given project.
:param project_id:
:type project_id: str | luigi/contrib/bigquery.py | def list_datasets(self, project_id):
"""Returns the list of datasets in a given project.
:param project_id:
:type project_id: str
"""
request = self.client.datasets().list(projectId=project_id,
maxResults=1000)
respons... | def list_datasets(self, project_id):
"""Returns the list of datasets in a given project.
:param project_id:
:type project_id: str
"""
request = self.client.datasets().list(projectId=project_id,
maxResults=1000)
respons... | [
"Returns",
"the",
"list",
"of",
"datasets",
"in",
"a",
"given",
"project",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L235-L254 | [
"def",
"list_datasets",
"(",
"self",
",",
"project_id",
")",
":",
"request",
"=",
"self",
".",
"client",
".",
"datasets",
"(",
")",
".",
"list",
"(",
"projectId",
"=",
"project_id",
",",
"maxResults",
"=",
"1000",
")",
"response",
"=",
"request",
".",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.list_tables | Returns the list of tables in a given dataset.
:param dataset:
:type dataset: BQDataset | luigi/contrib/bigquery.py | def list_tables(self, dataset):
"""Returns the list of tables in a given dataset.
:param dataset:
:type dataset: BQDataset
"""
request = self.client.tables().list(projectId=dataset.project_id,
datasetId=dataset.dataset_id,
... | def list_tables(self, dataset):
"""Returns the list of tables in a given dataset.
:param dataset:
:type dataset: BQDataset
"""
request = self.client.tables().list(projectId=dataset.project_id,
datasetId=dataset.dataset_id,
... | [
"Returns",
"the",
"list",
"of",
"tables",
"in",
"a",
"given",
"dataset",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L256-L276 | [
"def",
"list_tables",
"(",
"self",
",",
"dataset",
")",
":",
"request",
"=",
"self",
".",
"client",
".",
"tables",
"(",
")",
".",
"list",
"(",
"projectId",
"=",
"dataset",
".",
"project_id",
",",
"datasetId",
"=",
"dataset",
".",
"dataset_id",
",",
"ma... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.get_view | Returns the SQL query for a view, or None if it doesn't exist or is not a view.
:param table: The table containing the view.
:type table: BQTable | luigi/contrib/bigquery.py | def get_view(self, table):
"""Returns the SQL query for a view, or None if it doesn't exist or is not a view.
:param table: The table containing the view.
:type table: BQTable
"""
request = self.client.tables().get(projectId=table.project_id,
... | def get_view(self, table):
"""Returns the SQL query for a view, or None if it doesn't exist or is not a view.
:param table: The table containing the view.
:type table: BQTable
"""
request = self.client.tables().get(projectId=table.project_id,
... | [
"Returns",
"the",
"SQL",
"query",
"for",
"a",
"view",
"or",
"None",
"if",
"it",
"doesn",
"t",
"exist",
"or",
"is",
"not",
"a",
"view",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L278-L296 | [
"def",
"get_view",
"(",
"self",
",",
"table",
")",
":",
"request",
"=",
"self",
".",
"client",
".",
"tables",
"(",
")",
".",
"get",
"(",
"projectId",
"=",
"table",
".",
"project_id",
",",
"datasetId",
"=",
"table",
".",
"dataset_id",
",",
"tableId",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.update_view | Updates the SQL query for a view.
If the output table exists, it is replaced with the supplied view query. Otherwise a new
table is created with this view.
:param table: The table to contain the view.
:type table: BQTable
:param view: The SQL query for the view.
:type v... | luigi/contrib/bigquery.py | def update_view(self, table, view):
"""Updates the SQL query for a view.
If the output table exists, it is replaced with the supplied view query. Otherwise a new
table is created with this view.
:param table: The table to contain the view.
:type table: BQTable
:param vi... | def update_view(self, table, view):
"""Updates the SQL query for a view.
If the output table exists, it is replaced with the supplied view query. Otherwise a new
table is created with this view.
:param table: The table to contain the view.
:type table: BQTable
:param vi... | [
"Updates",
"the",
"SQL",
"query",
"for",
"a",
"view",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L298-L329 | [
"def",
"update_view",
"(",
"self",
",",
"table",
",",
"view",
")",
":",
"body",
"=",
"{",
"'tableReference'",
":",
"{",
"'projectId'",
":",
"table",
".",
"project_id",
",",
"'datasetId'",
":",
"table",
".",
"dataset_id",
",",
"'tableId'",
":",
"table",
"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.run_job | Runs a BigQuery "job". See the documentation for the format of body.
.. note::
You probably don't need to use this directly. Use the tasks defined below.
:param dataset:
:type dataset: BQDataset | luigi/contrib/bigquery.py | def run_job(self, project_id, body, dataset=None):
"""Runs a BigQuery "job". See the documentation for the format of body.
.. note::
You probably don't need to use this directly. Use the tasks defined below.
:param dataset:
:type dataset: BQDataset
"""
... | def run_job(self, project_id, body, dataset=None):
"""Runs a BigQuery "job". See the documentation for the format of body.
.. note::
You probably don't need to use this directly. Use the tasks defined below.
:param dataset:
:type dataset: BQDataset
"""
... | [
"Runs",
"a",
"BigQuery",
"job",
".",
"See",
"the",
"documentation",
"for",
"the",
"format",
"of",
"body",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L331-L355 | [
"def",
"run_job",
"(",
"self",
",",
"project_id",
",",
"body",
",",
"dataset",
"=",
"None",
")",
":",
"if",
"dataset",
"and",
"not",
"self",
".",
"dataset_exists",
"(",
"dataset",
")",
":",
"self",
".",
"make_dataset",
"(",
"dataset",
")",
"new_job",
"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryClient.copy | Copies (or appends) a table to another table.
:param source_table:
:type source_table: BQTable
:param dest_table:
:type dest_table: BQTable
:param create_disposition: whether to create the table if needed
:type create_disposition: CreateDispositio... | luigi/contrib/bigquery.py | def copy(self,
source_table,
dest_table,
create_disposition=CreateDisposition.CREATE_IF_NEEDED,
write_disposition=WriteDisposition.WRITE_TRUNCATE):
"""Copies (or appends) a table to another table.
:param source_table:
:type source_tabl... | def copy(self,
source_table,
dest_table,
create_disposition=CreateDisposition.CREATE_IF_NEEDED,
write_disposition=WriteDisposition.WRITE_TRUNCATE):
"""Copies (or appends) a table to another table.
:param source_table:
:type source_tabl... | [
"Copies",
"(",
"or",
"appends",
")",
"a",
"table",
"to",
"another",
"table",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L357-L393 | [
"def",
"copy",
"(",
"self",
",",
"source_table",
",",
"dest_table",
",",
"create_disposition",
"=",
"CreateDisposition",
".",
"CREATE_IF_NEEDED",
",",
"write_disposition",
"=",
"WriteDisposition",
".",
"WRITE_TRUNCATE",
")",
":",
"job",
"=",
"{",
"\"configuration\""... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryTarget.from_bqtable | A constructor that takes a :py:class:`BQTable`.
:param table:
:type table: BQTable | luigi/contrib/bigquery.py | def from_bqtable(cls, table, client=None):
"""A constructor that takes a :py:class:`BQTable`.
:param table:
:type table: BQTable
"""
return cls(table.project_id, table.dataset_id, table.table_id, client=client) | def from_bqtable(cls, table, client=None):
"""A constructor that takes a :py:class:`BQTable`.
:param table:
:type table: BQTable
"""
return cls(table.project_id, table.dataset_id, table.table_id, client=client) | [
"A",
"constructor",
"that",
"takes",
"a",
":",
"py",
":",
"class",
":",
"BQTable",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L402-L408 | [
"def",
"from_bqtable",
"(",
"cls",
",",
"table",
",",
"client",
"=",
"None",
")",
":",
"return",
"cls",
"(",
"table",
".",
"project_id",
",",
"table",
".",
"dataset_id",
",",
"table",
".",
"table_id",
",",
"client",
"=",
"client",
")"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryLoadTask.source_uris | The fully-qualified URIs that point to your data in Google Cloud Storage.
Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. | luigi/contrib/bigquery.py | def source_uris(self):
"""The fully-qualified URIs that point to your data in Google Cloud Storage.
Each URI can contain one '*' wildcard character and it must come after the 'bucket' name."""
return [x.path for x in luigi.task.flatten(self.input())] | def source_uris(self):
"""The fully-qualified URIs that point to your data in Google Cloud Storage.
Each URI can contain one '*' wildcard character and it must come after the 'bucket' name."""
return [x.path for x in luigi.task.flatten(self.input())] | [
"The",
"fully",
"-",
"qualified",
"URIs",
"that",
"point",
"to",
"your",
"data",
"in",
"Google",
"Cloud",
"Storage",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L487-L491 | [
"def",
"source_uris",
"(",
"self",
")",
":",
"return",
"[",
"x",
".",
"path",
"for",
"x",
"in",
"luigi",
".",
"task",
".",
"flatten",
"(",
"self",
".",
"input",
"(",
")",
")",
"]"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BigQueryExtractTask.destination_uris | The fully-qualified URIs that point to your data in Google Cloud
Storage. Each URI can contain one '*' wildcard character and it must
come after the 'bucket' name.
Wildcarded destinationUris in GCSQueryTarget might not be resolved
correctly and result in incomplete data. If a GCSQueryTa... | luigi/contrib/bigquery.py | def destination_uris(self):
"""
The fully-qualified URIs that point to your data in Google Cloud
Storage. Each URI can contain one '*' wildcard character and it must
come after the 'bucket' name.
Wildcarded destinationUris in GCSQueryTarget might not be resolved
correctl... | def destination_uris(self):
"""
The fully-qualified URIs that point to your data in Google Cloud
Storage. Each URI can contain one '*' wildcard character and it must
come after the 'bucket' name.
Wildcarded destinationUris in GCSQueryTarget might not be resolved
correctl... | [
"The",
"fully",
"-",
"qualified",
"URIs",
"that",
"point",
"to",
"your",
"data",
"in",
"Google",
"Cloud",
"Storage",
".",
"Each",
"URI",
"can",
"contain",
"one",
"*",
"wildcard",
"character",
"and",
"it",
"must",
"come",
"after",
"the",
"bucket",
"name",
... | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/bigquery.py#L701-L712 | [
"def",
"destination_uris",
"(",
"self",
")",
":",
"return",
"[",
"x",
".",
"path",
"for",
"x",
"in",
"luigi",
".",
"task",
".",
"flatten",
"(",
"self",
".",
"output",
"(",
")",
")",
"]"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | RemoteContext.Popen | Remote Popen. | luigi/contrib/ssh.py | def Popen(self, cmd, **kwargs):
"""
Remote Popen.
"""
prefixed_cmd = self._prepare_cmd(cmd)
return subprocess.Popen(prefixed_cmd, **kwargs) | def Popen(self, cmd, **kwargs):
"""
Remote Popen.
"""
prefixed_cmd = self._prepare_cmd(cmd)
return subprocess.Popen(prefixed_cmd, **kwargs) | [
"Remote",
"Popen",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/ssh.py#L116-L121 | [
"def",
"Popen",
"(",
"self",
",",
"cmd",
",",
"*",
"*",
"kwargs",
")",
":",
"prefixed_cmd",
"=",
"self",
".",
"_prepare_cmd",
"(",
"cmd",
")",
"return",
"subprocess",
".",
"Popen",
"(",
"prefixed_cmd",
",",
"*",
"*",
"kwargs",
")"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | RemoteContext.check_output | Execute a shell command remotely and return the output.
Simplified version of Popen when you only want the output as a string and detect any errors. | luigi/contrib/ssh.py | def check_output(self, cmd):
"""
Execute a shell command remotely and return the output.
Simplified version of Popen when you only want the output as a string and detect any errors.
"""
p = self.Popen(cmd, stdout=subprocess.PIPE)
output, _ = p.communicate()
if p.... | def check_output(self, cmd):
"""
Execute a shell command remotely and return the output.
Simplified version of Popen when you only want the output as a string and detect any errors.
"""
p = self.Popen(cmd, stdout=subprocess.PIPE)
output, _ = p.communicate()
if p.... | [
"Execute",
"a",
"shell",
"command",
"remotely",
"and",
"return",
"the",
"output",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/ssh.py#L123-L133 | [
"def",
"check_output",
"(",
"self",
",",
"cmd",
")",
":",
"p",
"=",
"self",
".",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"output",
",",
"_",
"=",
"p",
".",
"communicate",
"(",
")",
"if",
"p",
".",
"returncode",
"!... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | RemoteContext.tunnel | Open a tunnel between localhost:local_port and remote_host:remote_port via the host specified by this context.
Remember to close() the returned "tunnel" object in order to clean up
after yourself when you are done with the tunnel. | luigi/contrib/ssh.py | def tunnel(self, local_port, remote_port=None, remote_host="localhost"):
"""
Open a tunnel between localhost:local_port and remote_host:remote_port via the host specified by this context.
Remember to close() the returned "tunnel" object in order to clean up
after yourself when you are d... | def tunnel(self, local_port, remote_port=None, remote_host="localhost"):
"""
Open a tunnel between localhost:local_port and remote_host:remote_port via the host specified by this context.
Remember to close() the returned "tunnel" object in order to clean up
after yourself when you are d... | [
"Open",
"a",
"tunnel",
"between",
"localhost",
":",
"local_port",
"and",
"remote_host",
":",
"remote_port",
"via",
"the",
"host",
"specified",
"by",
"this",
"context",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/ssh.py#L136-L155 | [
"def",
"tunnel",
"(",
"self",
",",
"local_port",
",",
"remote_port",
"=",
"None",
",",
"remote_host",
"=",
"\"localhost\"",
")",
":",
"tunnel_host",
"=",
"\"{0}:{1}:{2}\"",
".",
"format",
"(",
"local_port",
",",
"remote_host",
",",
"remote_port",
")",
"proc",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | RemoteFileSystem.isdir | Return `True` if directory at `path` exist, False otherwise. | luigi/contrib/ssh.py | def isdir(self, path):
"""
Return `True` if directory at `path` exist, False otherwise.
"""
try:
self.remote_context.check_output(["test", "-d", path])
except subprocess.CalledProcessError as e:
if e.returncode == 1:
return False
... | def isdir(self, path):
"""
Return `True` if directory at `path` exist, False otherwise.
"""
try:
self.remote_context.check_output(["test", "-d", path])
except subprocess.CalledProcessError as e:
if e.returncode == 1:
return False
... | [
"Return",
"True",
"if",
"directory",
"at",
"path",
"exist",
"False",
"otherwise",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/ssh.py#L184-L195 | [
"def",
"isdir",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"self",
".",
"remote_context",
".",
"check_output",
"(",
"[",
"\"test\"",
",",
"\"-d\"",
",",
"path",
"]",
")",
"except",
"subprocess",
".",
"CalledProcessError",
"as",
"e",
":",
"if",
"e"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | RemoteFileSystem.remove | Remove file or directory at location `path`. | luigi/contrib/ssh.py | def remove(self, path, recursive=True):
"""
Remove file or directory at location `path`.
"""
if recursive:
cmd = ["rm", "-r", path]
else:
cmd = ["rm", path]
self.remote_context.check_output(cmd) | def remove(self, path, recursive=True):
"""
Remove file or directory at location `path`.
"""
if recursive:
cmd = ["rm", "-r", path]
else:
cmd = ["rm", path]
self.remote_context.check_output(cmd) | [
"Remove",
"file",
"or",
"directory",
"at",
"location",
"path",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/ssh.py#L197-L206 | [
"def",
"remove",
"(",
"self",
",",
"path",
",",
"recursive",
"=",
"True",
")",
":",
"if",
"recursive",
":",
"cmd",
"=",
"[",
"\"rm\"",
",",
"\"-r\"",
",",
"path",
"]",
"else",
":",
"cmd",
"=",
"[",
"\"rm\"",
",",
"path",
"]",
"self",
".",
"remote... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | getpcmd | Returns command of process.
:param pid: | luigi/lock.py | def getpcmd(pid):
"""
Returns command of process.
:param pid:
"""
if os.name == "nt":
# Use wmic command instead of ps on Windows.
cmd = 'wmic path win32_process where ProcessID=%s get Commandline 2> nul' % (pid, )
with os.popen(cmd, 'r') as p:
lines = [line for ... | def getpcmd(pid):
"""
Returns command of process.
:param pid:
"""
if os.name == "nt":
# Use wmic command instead of ps on Windows.
cmd = 'wmic path win32_process where ProcessID=%s get Commandline 2> nul' % (pid, )
with os.popen(cmd, 'r') as p:
lines = [line for ... | [
"Returns",
"command",
"of",
"process",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/lock.py#L33-L79 | [
"def",
"getpcmd",
"(",
"pid",
")",
":",
"if",
"os",
".",
"name",
"==",
"\"nt\"",
":",
"# Use wmic command instead of ps on Windows.",
"cmd",
"=",
"'wmic path win32_process where ProcessID=%s get Commandline 2> nul'",
"%",
"(",
"pid",
",",
")",
"with",
"os",
".",
"po... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | acquire_for | Makes sure the process is only run once at the same time with the same name.
Notice that we since we check the process name, different parameters to the same
command can spawn multiple processes at the same time, i.e. running
"/usr/bin/my_process" does not prevent anyone from launching
"/usr/bin/my_pro... | luigi/lock.py | def acquire_for(pid_dir, num_available=1, kill_signal=None):
"""
Makes sure the process is only run once at the same time with the same name.
Notice that we since we check the process name, different parameters to the same
command can spawn multiple processes at the same time, i.e. running
"/usr/bi... | def acquire_for(pid_dir, num_available=1, kill_signal=None):
"""
Makes sure the process is only run once at the same time with the same name.
Notice that we since we check the process name, different parameters to the same
command can spawn multiple processes at the same time, i.e. running
"/usr/bi... | [
"Makes",
"sure",
"the",
"process",
"is",
"only",
"run",
"once",
"at",
"the",
"same",
"time",
"with",
"the",
"same",
"name",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/lock.py#L94-L138 | [
"def",
"acquire_for",
"(",
"pid_dir",
",",
"num_available",
"=",
"1",
",",
"kill_signal",
"=",
"None",
")",
":",
"my_pid",
",",
"my_cmd",
",",
"pid_file",
"=",
"get_info",
"(",
"pid_dir",
")",
"# Create a pid file if it does not exist",
"try",
":",
"os",
".",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Failures.add_failure | Add a failure event with the current timestamp. | luigi/scheduler.py | def add_failure(self):
"""
Add a failure event with the current timestamp.
"""
failure_time = time.time()
if not self.first_failure_time:
self.first_failure_time = failure_time
self.failures.append(failure_time) | def add_failure(self):
"""
Add a failure event with the current timestamp.
"""
failure_time = time.time()
if not self.first_failure_time:
self.first_failure_time = failure_time
self.failures.append(failure_time) | [
"Add",
"a",
"failure",
"event",
"with",
"the",
"current",
"timestamp",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L179-L188 | [
"def",
"add_failure",
"(",
"self",
")",
":",
"failure_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"not",
"self",
".",
"first_failure_time",
":",
"self",
".",
"first_failure_time",
"=",
"failure_time",
"self",
".",
"failures",
".",
"append",
"(",
"fail... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Failures.num_failures | Return the number of failures in the window. | luigi/scheduler.py | def num_failures(self):
"""
Return the number of failures in the window.
"""
min_time = time.time() - self.window
while self.failures and self.failures[0] < min_time:
self.failures.popleft()
return len(self.failures) | def num_failures(self):
"""
Return the number of failures in the window.
"""
min_time = time.time() - self.window
while self.failures and self.failures[0] < min_time:
self.failures.popleft()
return len(self.failures) | [
"Return",
"the",
"number",
"of",
"failures",
"in",
"the",
"window",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L190-L199 | [
"def",
"num_failures",
"(",
"self",
")",
":",
"min_time",
"=",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"window",
"while",
"self",
".",
"failures",
"and",
"self",
".",
"failures",
"[",
"0",
"]",
"<",
"min_time",
":",
"self",
".",
"failures",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Worker.is_trivial_worker | If it's not an assistant having only tasks that are without
requirements.
We have to pass the state parameter for optimization reasons. | luigi/scheduler.py | def is_trivial_worker(self, state):
"""
If it's not an assistant having only tasks that are without
requirements.
We have to pass the state parameter for optimization reasons.
"""
if self.assistant:
return False
return all(not task.resources for task ... | def is_trivial_worker(self, state):
"""
If it's not an assistant having only tasks that are without
requirements.
We have to pass the state parameter for optimization reasons.
"""
if self.assistant:
return False
return all(not task.resources for task ... | [
"If",
"it",
"s",
"not",
"an",
"assistant",
"having",
"only",
"tasks",
"that",
"are",
"without",
"requirements",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L401-L410 | [
"def",
"is_trivial_worker",
"(",
"self",
",",
"state",
")",
":",
"if",
"self",
".",
"assistant",
":",
"return",
"False",
"return",
"all",
"(",
"not",
"task",
".",
"resources",
"for",
"task",
"in",
"self",
".",
"get_tasks",
"(",
"state",
",",
"PENDING",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SimpleTaskState.num_pending_tasks | Return how many tasks are PENDING + RUNNING. O(1). | luigi/scheduler.py | def num_pending_tasks(self):
"""
Return how many tasks are PENDING + RUNNING. O(1).
"""
return len(self._status_tasks[PENDING]) + len(self._status_tasks[RUNNING]) | def num_pending_tasks(self):
"""
Return how many tasks are PENDING + RUNNING. O(1).
"""
return len(self._status_tasks[PENDING]) + len(self._status_tasks[RUNNING]) | [
"Return",
"how",
"many",
"tasks",
"are",
"PENDING",
"+",
"RUNNING",
".",
"O",
"(",
"1",
")",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L518-L522 | [
"def",
"num_pending_tasks",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_status_tasks",
"[",
"PENDING",
"]",
")",
"+",
"len",
"(",
"self",
".",
"_status_tasks",
"[",
"RUNNING",
"]",
")"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Scheduler._update_priority | Update priority of the given task.
Priority can only be increased.
If the task doesn't exist, a placeholder task is created to preserve priority when the task is later scheduled. | luigi/scheduler.py | def _update_priority(self, task, prio, worker):
"""
Update priority of the given task.
Priority can only be increased.
If the task doesn't exist, a placeholder task is created to preserve priority when the task is later scheduled.
"""
task.priority = prio = max(prio, tas... | def _update_priority(self, task, prio, worker):
"""
Update priority of the given task.
Priority can only be increased.
If the task doesn't exist, a placeholder task is created to preserve priority when the task is later scheduled.
"""
task.priority = prio = max(prio, tas... | [
"Update",
"priority",
"of",
"the",
"given",
"task",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L771-L782 | [
"def",
"_update_priority",
"(",
"self",
",",
"task",
",",
"prio",
",",
"worker",
")",
":",
"task",
".",
"priority",
"=",
"prio",
"=",
"max",
"(",
"prio",
",",
"task",
".",
"priority",
")",
"for",
"dep",
"in",
"task",
".",
"deps",
"or",
"[",
"]",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Scheduler.add_task | * add task identified by task_id if it doesn't exist
* if deps is not None, update dependency list
* update status of task
* add additional workers/stakeholders
* update priority when needed | luigi/scheduler.py | def add_task(self, task_id=None, status=PENDING, runnable=True,
deps=None, new_deps=None, expl=None, resources=None,
priority=0, family='', module=None, params=None, param_visibilities=None, accepts_messages=False,
assistant=False, tracking_url=None, worker=None, batch... | def add_task(self, task_id=None, status=PENDING, runnable=True,
deps=None, new_deps=None, expl=None, resources=None,
priority=0, family='', module=None, params=None, param_visibilities=None, accepts_messages=False,
assistant=False, tracking_url=None, worker=None, batch... | [
"*",
"add",
"task",
"identified",
"by",
"task_id",
"if",
"it",
"doesn",
"t",
"exist",
"*",
"if",
"deps",
"is",
"not",
"None",
"update",
"dependency",
"list",
"*",
"update",
"status",
"of",
"task",
"*",
"add",
"additional",
"workers",
"/",
"stakeholders",
... | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L803-L940 | [
"def",
"add_task",
"(",
"self",
",",
"task_id",
"=",
"None",
",",
"status",
"=",
"PENDING",
",",
"runnable",
"=",
"True",
",",
"deps",
"=",
"None",
",",
"new_deps",
"=",
"None",
",",
"expl",
"=",
"None",
",",
"resources",
"=",
"None",
",",
"priority"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Scheduler._traverse_graph | Returns the dependency graph rooted at task_id
This does a breadth-first traversal to find the nodes closest to the
root before hitting the scheduler.max_graph_nodes limit.
:param root_task_id: the id of the graph's root
:return: A map of task id to serialized node | luigi/scheduler.py | def _traverse_graph(self, root_task_id, seen=None, dep_func=None, include_done=True):
""" Returns the dependency graph rooted at task_id
This does a breadth-first traversal to find the nodes closest to the
root before hitting the scheduler.max_graph_nodes limit.
:param root_task_id: th... | def _traverse_graph(self, root_task_id, seen=None, dep_func=None, include_done=True):
""" Returns the dependency graph rooted at task_id
This does a breadth-first traversal to find the nodes closest to the
root before hitting the scheduler.max_graph_nodes limit.
:param root_task_id: th... | [
"Returns",
"the",
"dependency",
"graph",
"rooted",
"at",
"task_id"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L1343-L1402 | [
"def",
"_traverse_graph",
"(",
"self",
",",
"root_task_id",
",",
"seen",
"=",
"None",
",",
"dep_func",
"=",
"None",
",",
"include_done",
"=",
"True",
")",
":",
"if",
"seen",
"is",
"None",
":",
"seen",
"=",
"set",
"(",
")",
"elif",
"root_task_id",
"in",... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Scheduler.task_list | Query for a subset of tasks by status. | luigi/scheduler.py | def task_list(self, status='', upstream_status='', limit=True, search=None, max_shown_tasks=None,
**kwargs):
"""
Query for a subset of tasks by status.
"""
if not search:
count_limit = max_shown_tasks or self._config.max_shown_tasks
pre_count = s... | def task_list(self, status='', upstream_status='', limit=True, search=None, max_shown_tasks=None,
**kwargs):
"""
Query for a subset of tasks by status.
"""
if not search:
count_limit = max_shown_tasks or self._config.max_shown_tasks
pre_count = s... | [
"Query",
"for",
"a",
"subset",
"of",
"tasks",
"by",
"status",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L1424-L1454 | [
"def",
"task_list",
"(",
"self",
",",
"status",
"=",
"''",
",",
"upstream_status",
"=",
"''",
",",
"limit",
"=",
"True",
",",
"search",
"=",
"None",
",",
"max_shown_tasks",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"search",
":",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Scheduler.resource_list | Resources usage info and their consumers (tasks). | luigi/scheduler.py | def resource_list(self):
"""
Resources usage info and their consumers (tasks).
"""
self.prune()
resources = [
dict(
name=resource,
num_total=r_dict['total'],
num_used=r_dict['used']
) for resource, r_dict in ... | def resource_list(self):
"""
Resources usage info and their consumers (tasks).
"""
self.prune()
resources = [
dict(
name=resource,
num_total=r_dict['total'],
num_used=r_dict['used']
) for resource, r_dict in ... | [
"Resources",
"usage",
"info",
"and",
"their",
"consumers",
"(",
"tasks",
")",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L1500-L1521 | [
"def",
"resource_list",
"(",
"self",
")",
":",
"self",
".",
"prune",
"(",
")",
"resources",
"=",
"[",
"dict",
"(",
"name",
"=",
"resource",
",",
"num_total",
"=",
"r_dict",
"[",
"'total'",
"]",
",",
"num_used",
"=",
"r_dict",
"[",
"'used'",
"]",
")",... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Scheduler.resources | get total resources and available ones | luigi/scheduler.py | def resources(self):
''' get total resources and available ones '''
used_resources = self._used_resources()
ret = collections.defaultdict(dict)
for resource, total in six.iteritems(self._resources):
ret[resource]['total'] = total
if resource in used_resources:
... | def resources(self):
''' get total resources and available ones '''
used_resources = self._used_resources()
ret = collections.defaultdict(dict)
for resource, total in six.iteritems(self._resources):
ret[resource]['total'] = total
if resource in used_resources:
... | [
"get",
"total",
"resources",
"and",
"available",
"ones"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L1523-L1533 | [
"def",
"resources",
"(",
"self",
")",
":",
"used_resources",
"=",
"self",
".",
"_used_resources",
"(",
")",
"ret",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"for",
"resource",
",",
"total",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Scheduler.task_search | Query for a subset of tasks by task_id.
:param task_str:
:return: | luigi/scheduler.py | def task_search(self, task_str, **kwargs):
"""
Query for a subset of tasks by task_id.
:param task_str:
:return:
"""
self.prune()
result = collections.defaultdict(dict)
for task in self._state.get_active_tasks():
if task.id.find(task_str) != -... | def task_search(self, task_str, **kwargs):
"""
Query for a subset of tasks by task_id.
:param task_str:
:return:
"""
self.prune()
result = collections.defaultdict(dict)
for task in self._state.get_active_tasks():
if task.id.find(task_str) != -... | [
"Query",
"for",
"a",
"subset",
"of",
"tasks",
"by",
"task_id",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/scheduler.py#L1536-L1549 | [
"def",
"task_search",
"(",
"self",
",",
"task_str",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"prune",
"(",
")",
"result",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"for",
"task",
"in",
"self",
".",
"_state",
".",
"get_active_task... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | FileSystemTarget.exists | Returns ``True`` if the path for this FileSystemTarget exists; ``False`` otherwise.
This method is implemented by using :py:attr:`fs`. | luigi/target.py | def exists(self):
"""
Returns ``True`` if the path for this FileSystemTarget exists; ``False`` otherwise.
This method is implemented by using :py:attr:`fs`.
"""
path = self.path
if '*' in path or '?' in path or '[' in path or '{' in path:
logger.warning("Usin... | def exists(self):
"""
Returns ``True`` if the path for this FileSystemTarget exists; ``False`` otherwise.
This method is implemented by using :py:attr:`fs`.
"""
path = self.path
if '*' in path or '?' in path or '[' in path or '{' in path:
logger.warning("Usin... | [
"Returns",
"True",
"if",
"the",
"path",
"for",
"this",
"FileSystemTarget",
"exists",
";",
"False",
"otherwise",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/target.py#L242-L252 | [
"def",
"exists",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"path",
"if",
"'*'",
"in",
"path",
"or",
"'?'",
"in",
"path",
"or",
"'['",
"in",
"path",
"or",
"'{'",
"in",
"path",
":",
"logger",
".",
"warning",
"(",
"\"Using wildcards in path %s migh... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | FileSystemTarget.temporary_path | A context manager that enables a reasonably short, general and
magic-less way to solve the :ref:`AtomicWrites`.
* On *entering*, it will create the parent directories so the
temporary_path is writeable right away.
This step uses :py:meth:`FileSystem.mkdir`.
* On *exiting... | luigi/target.py | def temporary_path(self):
"""
A context manager that enables a reasonably short, general and
magic-less way to solve the :ref:`AtomicWrites`.
* On *entering*, it will create the parent directories so the
temporary_path is writeable right away.
This step uses :py:m... | def temporary_path(self):
"""
A context manager that enables a reasonably short, general and
magic-less way to solve the :ref:`AtomicWrites`.
* On *entering*, it will create the parent directories so the
temporary_path is writeable right away.
This step uses :py:m... | [
"A",
"context",
"manager",
"that",
"enables",
"a",
"reasonably",
"short",
"general",
"and",
"magic",
"-",
"less",
"way",
"to",
"solve",
"the",
":",
"ref",
":",
"AtomicWrites",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/target.py#L263-L301 | [
"def",
"temporary_path",
"(",
"self",
")",
":",
"num",
"=",
"random",
".",
"randrange",
"(",
"0",
",",
"1e10",
")",
"slashless_path",
"=",
"self",
".",
"path",
".",
"rstrip",
"(",
"'/'",
")",
".",
"rstrip",
"(",
"\"\\\\\"",
")",
"_temp_path",
"=",
"'... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | ElasticsearchTarget.marker_index_document_id | Generate an id for the indicator document. | luigi/contrib/esindex.py | def marker_index_document_id(self):
"""
Generate an id for the indicator document.
"""
params = '%s:%s:%s' % (self.index, self.doc_type, self.update_id)
return hashlib.sha1(params.encode('utf-8')).hexdigest() | def marker_index_document_id(self):
"""
Generate an id for the indicator document.
"""
params = '%s:%s:%s' % (self.index, self.doc_type, self.update_id)
return hashlib.sha1(params.encode('utf-8')).hexdigest() | [
"Generate",
"an",
"id",
"for",
"the",
"indicator",
"document",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L161-L166 | [
"def",
"marker_index_document_id",
"(",
"self",
")",
":",
"params",
"=",
"'%s:%s:%s'",
"%",
"(",
"self",
".",
"index",
",",
"self",
".",
"doc_type",
",",
"self",
".",
"update_id",
")",
"return",
"hashlib",
".",
"sha1",
"(",
"params",
".",
"encode",
"(",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | ElasticsearchTarget.touch | Mark this update as complete.
The document id would be sufficent but,
for documentation,
we index the parameters `update_id`, `target_index`, `target_doc_type` and `date` as well. | luigi/contrib/esindex.py | def touch(self):
"""
Mark this update as complete.
The document id would be sufficent but,
for documentation,
we index the parameters `update_id`, `target_index`, `target_doc_type` and `date` as well.
"""
self.create_marker_index()
self.es.index(index=sel... | def touch(self):
"""
Mark this update as complete.
The document id would be sufficent but,
for documentation,
we index the parameters `update_id`, `target_index`, `target_doc_type` and `date` as well.
"""
self.create_marker_index()
self.es.index(index=sel... | [
"Mark",
"this",
"update",
"as",
"complete",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L168-L184 | [
"def",
"touch",
"(",
"self",
")",
":",
"self",
".",
"create_marker_index",
"(",
")",
"self",
".",
"es",
".",
"index",
"(",
"index",
"=",
"self",
".",
"marker_index",
",",
"doc_type",
"=",
"self",
".",
"marker_doc_type",
",",
"id",
"=",
"self",
".",
"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | ElasticsearchTarget.exists | Test, if this task has been run. | luigi/contrib/esindex.py | def exists(self):
"""
Test, if this task has been run.
"""
try:
self.es.get(index=self.marker_index, doc_type=self.marker_doc_type, id=self.marker_index_document_id())
return True
except elasticsearch.NotFoundError:
logger.debug('Marker documen... | def exists(self):
"""
Test, if this task has been run.
"""
try:
self.es.get(index=self.marker_index, doc_type=self.marker_doc_type, id=self.marker_index_document_id())
return True
except elasticsearch.NotFoundError:
logger.debug('Marker documen... | [
"Test",
"if",
"this",
"task",
"has",
"been",
"run",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L186-L197 | [
"def",
"exists",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"es",
".",
"get",
"(",
"index",
"=",
"self",
".",
"marker_index",
",",
"doc_type",
"=",
"self",
".",
"marker_doc_type",
",",
"id",
"=",
"self",
".",
"marker_index_document_id",
"(",
")",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | ElasticsearchTarget.create_marker_index | Create the index that will keep track of the tasks if necessary. | luigi/contrib/esindex.py | def create_marker_index(self):
"""
Create the index that will keep track of the tasks if necessary.
"""
if not self.es.indices.exists(index=self.marker_index):
self.es.indices.create(index=self.marker_index) | def create_marker_index(self):
"""
Create the index that will keep track of the tasks if necessary.
"""
if not self.es.indices.exists(index=self.marker_index):
self.es.indices.create(index=self.marker_index) | [
"Create",
"the",
"index",
"that",
"will",
"keep",
"track",
"of",
"the",
"tasks",
"if",
"necessary",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L199-L204 | [
"def",
"create_marker_index",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"es",
".",
"indices",
".",
"exists",
"(",
"index",
"=",
"self",
".",
"marker_index",
")",
":",
"self",
".",
"es",
".",
"indices",
".",
"create",
"(",
"index",
"=",
"self",... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | ElasticsearchTarget.ensure_hist_size | Shrink the history of updates for
a `index/doc_type` combination down to `self.marker_index_hist_size`. | luigi/contrib/esindex.py | def ensure_hist_size(self):
"""
Shrink the history of updates for
a `index/doc_type` combination down to `self.marker_index_hist_size`.
"""
if self.marker_index_hist_size == 0:
return
result = self.es.search(index=self.marker_index,
... | def ensure_hist_size(self):
"""
Shrink the history of updates for
a `index/doc_type` combination down to `self.marker_index_hist_size`.
"""
if self.marker_index_hist_size == 0:
return
result = self.es.search(index=self.marker_index,
... | [
"Shrink",
"the",
"history",
"of",
"updates",
"for",
"a",
"index",
"/",
"doc_type",
"combination",
"down",
"to",
"self",
".",
"marker_index_hist_size",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L206-L224 | [
"def",
"ensure_hist_size",
"(",
"self",
")",
":",
"if",
"self",
".",
"marker_index_hist_size",
"==",
"0",
":",
"return",
"result",
"=",
"self",
".",
"es",
".",
"search",
"(",
"index",
"=",
"self",
".",
"marker_index",
",",
"doc_type",
"=",
"self",
".",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToIndex._docs | Since `self.docs` may yield documents that do not explicitly contain `_index` or `_type`,
add those attributes here, if necessary. | luigi/contrib/esindex.py | def _docs(self):
"""
Since `self.docs` may yield documents that do not explicitly contain `_index` or `_type`,
add those attributes here, if necessary.
"""
iterdocs = iter(self.docs())
first = next(iterdocs)
needs_parsing = False
if isinstance(first, six.s... | def _docs(self):
"""
Since `self.docs` may yield documents that do not explicitly contain `_index` or `_type`,
add those attributes here, if necessary.
"""
iterdocs = iter(self.docs())
first = next(iterdocs)
needs_parsing = False
if isinstance(first, six.s... | [
"Since",
"self",
".",
"docs",
"may",
"yield",
"documents",
"that",
"do",
"not",
"explicitly",
"contain",
"_index",
"or",
"_type",
"add",
"those",
"attributes",
"here",
"if",
"necessary",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L361-L382 | [
"def",
"_docs",
"(",
"self",
")",
":",
"iterdocs",
"=",
"iter",
"(",
"self",
".",
"docs",
"(",
")",
")",
"first",
"=",
"next",
"(",
"iterdocs",
")",
"needs_parsing",
"=",
"False",
"if",
"isinstance",
"(",
"first",
",",
"six",
".",
"string_types",
")"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToIndex.create_index | Override to provide code for creating the target index.
By default it will be created without any special settings or mappings. | luigi/contrib/esindex.py | def create_index(self):
"""
Override to provide code for creating the target index.
By default it will be created without any special settings or mappings.
"""
es = self._init_connection()
if not es.indices.exists(index=self.index):
es.indices.create(index=se... | def create_index(self):
"""
Override to provide code for creating the target index.
By default it will be created without any special settings or mappings.
"""
es = self._init_connection()
if not es.indices.exists(index=self.index):
es.indices.create(index=se... | [
"Override",
"to",
"provide",
"code",
"for",
"creating",
"the",
"target",
"index",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L394-L402 | [
"def",
"create_index",
"(",
"self",
")",
":",
"es",
"=",
"self",
".",
"_init_connection",
"(",
")",
"if",
"not",
"es",
".",
"indices",
".",
"exists",
"(",
"index",
"=",
"self",
".",
"index",
")",
":",
"es",
".",
"indices",
".",
"create",
"(",
"inde... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToIndex.delete_index | Delete the index, if it exists. | luigi/contrib/esindex.py | def delete_index(self):
"""
Delete the index, if it exists.
"""
es = self._init_connection()
if es.indices.exists(index=self.index):
es.indices.delete(index=self.index) | def delete_index(self):
"""
Delete the index, if it exists.
"""
es = self._init_connection()
if es.indices.exists(index=self.index):
es.indices.delete(index=self.index) | [
"Delete",
"the",
"index",
"if",
"it",
"exists",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L404-L410 | [
"def",
"delete_index",
"(",
"self",
")",
":",
"es",
"=",
"self",
".",
"_init_connection",
"(",
")",
"if",
"es",
".",
"indices",
".",
"exists",
"(",
"index",
"=",
"self",
".",
"index",
")",
":",
"es",
".",
"indices",
".",
"delete",
"(",
"index",
"="... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToIndex.output | Returns a ElasticsearchTarget representing the inserted dataset.
Normally you don't override this. | luigi/contrib/esindex.py | def output(self):
"""
Returns a ElasticsearchTarget representing the inserted dataset.
Normally you don't override this.
"""
return ElasticsearchTarget(
host=self.host,
port=self.port,
http_auth=self.http_auth,
index=self.index,
... | def output(self):
"""
Returns a ElasticsearchTarget representing the inserted dataset.
Normally you don't override this.
"""
return ElasticsearchTarget(
host=self.host,
port=self.port,
http_auth=self.http_auth,
index=self.index,
... | [
"Returns",
"a",
"ElasticsearchTarget",
"representing",
"the",
"inserted",
"dataset",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L418-L434 | [
"def",
"output",
"(",
"self",
")",
":",
"return",
"ElasticsearchTarget",
"(",
"host",
"=",
"self",
".",
"host",
",",
"port",
"=",
"self",
".",
"port",
",",
"http_auth",
"=",
"self",
".",
"http_auth",
",",
"index",
"=",
"self",
".",
"index",
",",
"doc... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToIndex.run | Run task, namely:
* purge existing index, if requested (`purge_existing_index`),
* create the index, if missing,
* apply mappings, if given,
* set refresh interval to -1 (disable) for performance reasons,
* bulk index in batches of size `chunk_size` (2000),
* set refresh... | luigi/contrib/esindex.py | def run(self):
"""
Run task, namely:
* purge existing index, if requested (`purge_existing_index`),
* create the index, if missing,
* apply mappings, if given,
* set refresh interval to -1 (disable) for performance reasons,
* bulk index in batches of size `chunk_... | def run(self):
"""
Run task, namely:
* purge existing index, if requested (`purge_existing_index`),
* create the index, if missing,
* apply mappings, if given,
* set refresh interval to -1 (disable) for performance reasons,
* bulk index in batches of size `chunk_... | [
"Run",
"task",
"namely",
":"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/esindex.py#L436-L465 | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"purge_existing_index",
":",
"self",
".",
"delete_index",
"(",
")",
"self",
".",
"create_index",
"(",
")",
"es",
"=",
"self",
".",
"_init_connection",
"(",
")",
"if",
"self",
".",
"mapping",
":",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | LuigiConfigParser._get_with_default | Gets the value of the section/option using method.
Returns default if value is not found.
Raises an exception if the default value is not None and doesn't match the expected_type. | luigi/configuration/cfg_parser.py | def _get_with_default(self, method, section, option, default, expected_type=None, **kwargs):
"""
Gets the value of the section/option using method.
Returns default if value is not found.
Raises an exception if the default value is not None and doesn't match the expected_type.
"... | def _get_with_default(self, method, section, option, default, expected_type=None, **kwargs):
"""
Gets the value of the section/option using method.
Returns default if value is not found.
Raises an exception if the default value is not None and doesn't match the expected_type.
"... | [
"Gets",
"the",
"value",
"of",
"the",
"section",
"/",
"option",
"using",
"method",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/configuration/cfg_parser.py#L156-L183 | [
"def",
"_get_with_default",
"(",
"self",
",",
"method",
",",
"section",
",",
"option",
",",
"default",
",",
"expected_type",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"try",
":",
"# Underscore-style is the recommended configuration style",
"opt... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | KubernetesJobTask.__track_job | Poll job status while active | luigi/contrib/kubernetes.py | def __track_job(self):
"""Poll job status while active"""
while not self.__verify_job_has_started():
time.sleep(self.__POLL_TIME)
self.__logger.debug("Waiting for Kubernetes job " + self.uu_name + " to start")
self.__print_kubectl_hints()
status = self.__get_job_... | def __track_job(self):
"""Poll job status while active"""
while not self.__verify_job_has_started():
time.sleep(self.__POLL_TIME)
self.__logger.debug("Waiting for Kubernetes job " + self.uu_name + " to start")
self.__print_kubectl_hints()
status = self.__get_job_... | [
"Poll",
"job",
"status",
"while",
"active"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/kubernetes.py#L211-L228 | [
"def",
"__track_job",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"__verify_job_has_started",
"(",
")",
":",
"time",
".",
"sleep",
"(",
"self",
".",
"__POLL_TIME",
")",
"self",
".",
"__logger",
".",
"debug",
"(",
"\"Waiting for Kubernetes job \"",
"+... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | KubernetesJobTask.__verify_job_has_started | Asserts that the job has successfully started | luigi/contrib/kubernetes.py | def __verify_job_has_started(self):
"""Asserts that the job has successfully started"""
# Verify that the job started
self.__get_job()
# Verify that the pod started
pods = self.__get_pods()
assert len(pods) > 0, "No pod scheduled by " + self.uu_name
for pod in p... | def __verify_job_has_started(self):
"""Asserts that the job has successfully started"""
# Verify that the job started
self.__get_job()
# Verify that the pod started
pods = self.__get_pods()
assert len(pods) > 0, "No pod scheduled by " + self.uu_name
for pod in p... | [
"Asserts",
"that",
"the",
"job",
"has",
"successfully",
"started"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/kubernetes.py#L267-L296 | [
"def",
"__verify_job_has_started",
"(",
"self",
")",
":",
"# Verify that the job started",
"self",
".",
"__get_job",
"(",
")",
"# Verify that the pod started",
"pods",
"=",
"self",
".",
"__get_pods",
"(",
")",
"assert",
"len",
"(",
"pods",
")",
">",
"0",
",",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | KubernetesJobTask.__get_job_status | Return the Kubernetes job status | luigi/contrib/kubernetes.py | def __get_job_status(self):
"""Return the Kubernetes job status"""
# Figure out status and return it
job = self.__get_job()
if "succeeded" in job.obj["status"] and job.obj["status"]["succeeded"] > 0:
job.scale(replicas=0)
if self.print_pod_logs_on_exit:
... | def __get_job_status(self):
"""Return the Kubernetes job status"""
# Figure out status and return it
job = self.__get_job()
if "succeeded" in job.obj["status"] and job.obj["status"]["succeeded"] > 0:
job.scale(replicas=0)
if self.print_pod_logs_on_exit:
... | [
"Return",
"the",
"Kubernetes",
"job",
"status"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/kubernetes.py#L298-L320 | [
"def",
"__get_job_status",
"(",
"self",
")",
":",
"# Figure out status and return it",
"job",
"=",
"self",
".",
"__get_job",
"(",
")",
"if",
"\"succeeded\"",
"in",
"job",
".",
"obj",
"[",
"\"status\"",
"]",
"and",
"job",
".",
"obj",
"[",
"\"status\"",
"]",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SQLAlchemyTarget.engine | Return an engine instance, creating it if it doesn't exist.
Recreate the engine connection if it wasn't originally created
by the current process. | luigi/contrib/sqla.py | def engine(self):
"""
Return an engine instance, creating it if it doesn't exist.
Recreate the engine connection if it wasn't originally created
by the current process.
"""
pid = os.getpid()
conn = SQLAlchemyTarget._engine_dict.get(self.connection_string)
... | def engine(self):
"""
Return an engine instance, creating it if it doesn't exist.
Recreate the engine connection if it wasn't originally created
by the current process.
"""
pid = os.getpid()
conn = SQLAlchemyTarget._engine_dict.get(self.connection_string)
... | [
"Return",
"an",
"engine",
"instance",
"creating",
"it",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/sqla.py#L193-L210 | [
"def",
"engine",
"(",
"self",
")",
":",
"pid",
"=",
"os",
".",
"getpid",
"(",
")",
"conn",
"=",
"SQLAlchemyTarget",
".",
"_engine_dict",
".",
"get",
"(",
"self",
".",
"connection_string",
")",
"if",
"not",
"conn",
"or",
"conn",
".",
"pid",
"!=",
"pid... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SQLAlchemyTarget.touch | Mark this update as complete. | luigi/contrib/sqla.py | def touch(self):
"""
Mark this update as complete.
"""
if self.marker_table_bound is None:
self.create_marker_table()
table = self.marker_table_bound
id_exists = self.exists()
with self.engine.begin() as conn:
if not id_exists:
... | def touch(self):
"""
Mark this update as complete.
"""
if self.marker_table_bound is None:
self.create_marker_table()
table = self.marker_table_bound
id_exists = self.exists()
with self.engine.begin() as conn:
if not id_exists:
... | [
"Mark",
"this",
"update",
"as",
"complete",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/sqla.py#L212-L231 | [
"def",
"touch",
"(",
"self",
")",
":",
"if",
"self",
".",
"marker_table_bound",
"is",
"None",
":",
"self",
".",
"create_marker_table",
"(",
")",
"table",
"=",
"self",
".",
"marker_table_bound",
"id_exists",
"=",
"self",
".",
"exists",
"(",
")",
"with",
"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SQLAlchemyTarget.create_marker_table | Create marker table if it doesn't exist.
Using a separate connection since the transaction might have to be reset. | luigi/contrib/sqla.py | 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.
"""
if self.marker_table is None:
self.marker_table = luigi.configuration.get_config().get('sqlalchemy', 'marker-tabl... | 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.
"""
if self.marker_table is None:
self.marker_table = luigi.configuration.get_config().get('sqlalchemy', 'marker-tabl... | [
"Create",
"marker",
"table",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/sqla.py#L244-L266 | [
"def",
"create_marker_table",
"(",
"self",
")",
":",
"if",
"self",
".",
"marker_table",
"is",
"None",
":",
"self",
".",
"marker_table",
"=",
"luigi",
".",
"configuration",
".",
"get_config",
"(",
")",
".",
"get",
"(",
"'sqlalchemy'",
",",
"'marker-table'",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToTable.create_table | Override to provide code for creating the target table.
By default it will be created using types specified in columns.
If the table exists, then it binds to the existing table.
If overridden, use the provided connection object for setting up the table in order to
create the table and ... | luigi/contrib/sqla.py | def create_table(self, engine):
"""
Override to provide code for creating the target table.
By default it will be created using types specified in columns.
If the table exists, then it binds to the existing table.
If overridden, use the provided connection object for setting up... | def create_table(self, engine):
"""
Override to provide code for creating the target table.
By default it will be created using types specified in columns.
If the table exists, then it binds to the existing table.
If overridden, use the provided connection object for setting up... | [
"Override",
"to",
"provide",
"code",
"for",
"creating",
"the",
"target",
"table",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/sqla.py#L318-L357 | [
"def",
"create_table",
"(",
"self",
",",
"engine",
")",
":",
"def",
"construct_sqla_columns",
"(",
"columns",
")",
":",
"retval",
"=",
"[",
"sqlalchemy",
".",
"Column",
"(",
"*",
"c",
"[",
"0",
"]",
",",
"*",
"*",
"c",
"[",
"1",
"]",
")",
"for",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToTable.copy | This method does the actual insertion of the rows of data given by ins_rows into the
database. A task that needs row updates instead of insertions should overload this method.
:param conn: The sqlalchemy connection object
:param ins_rows: The dictionary of rows with the keys in the format _<colu... | luigi/contrib/sqla.py | def copy(self, conn, ins_rows, table_bound):
"""
This method does the actual insertion of the rows of data given by ins_rows into the
database. A task that needs row updates instead of insertions should overload this method.
:param conn: The sqlalchemy connection object
:param in... | def copy(self, conn, ins_rows, table_bound):
"""
This method does the actual insertion of the rows of data given by ins_rows into the
database. A task that needs row updates instead of insertions should overload this method.
:param conn: The sqlalchemy connection object
:param in... | [
"This",
"method",
"does",
"the",
"actual",
"insertion",
"of",
"the",
"rows",
"of",
"data",
"given",
"by",
"ins_rows",
"into",
"the",
"database",
".",
"A",
"task",
"that",
"needs",
"row",
"updates",
"instead",
"of",
"insertions",
"should",
"overload",
"this",... | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/sqla.py#L400-L413 | [
"def",
"copy",
"(",
"self",
",",
"conn",
",",
"ins_rows",
",",
"table_bound",
")",
":",
"bound_cols",
"=",
"dict",
"(",
"(",
"c",
",",
"sqlalchemy",
".",
"bindparam",
"(",
"\"_\"",
"+",
"c",
".",
"key",
")",
")",
"for",
"c",
"in",
"table_bound",
".... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | main | Run the work() method from the class instance in the file "job-instance.pickle". | luigi/contrib/lsf_runner.py | def main(args=sys.argv):
"""Run the work() method from the class instance in the file "job-instance.pickle".
"""
try:
# Set up logging.
logging.basicConfig(level=logging.WARN)
work_dir = args[1]
assert os.path.exists(work_dir), "First argument to lsf_runner.py must be a direc... | def main(args=sys.argv):
"""Run the work() method from the class instance in the file "job-instance.pickle".
"""
try:
# Set up logging.
logging.basicConfig(level=logging.WARN)
work_dir = args[1]
assert os.path.exists(work_dir), "First argument to lsf_runner.py must be a direc... | [
"Run",
"the",
"work",
"()",
"method",
"from",
"the",
"class",
"instance",
"in",
"the",
"file",
"job",
"-",
"instance",
".",
"pickle",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/lsf_runner.py#L67-L79 | [
"def",
"main",
"(",
"args",
"=",
"sys",
".",
"argv",
")",
":",
"try",
":",
"# Set up logging.",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"WARN",
")",
"work_dir",
"=",
"args",
"[",
"1",
"]",
"assert",
"os",
".",
"path",
".",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | HdfsTarget.rename | Does not change self.path.
Unlike ``move_dir()``, ``rename()`` might cause nested directories.
See spotify/luigi#522 | luigi/contrib/hdfs/target.py | def rename(self, path, raise_if_exists=False):
"""
Does not change self.path.
Unlike ``move_dir()``, ``rename()`` might cause nested directories.
See spotify/luigi#522
"""
if isinstance(path, HdfsTarget):
path = path.path
if raise_if_exists and self.f... | def rename(self, path, raise_if_exists=False):
"""
Does not change self.path.
Unlike ``move_dir()``, ``rename()`` might cause nested directories.
See spotify/luigi#522
"""
if isinstance(path, HdfsTarget):
path = path.path
if raise_if_exists and self.f... | [
"Does",
"not",
"change",
"self",
".",
"path",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/target.py#L121-L132 | [
"def",
"rename",
"(",
"self",
",",
"path",
",",
"raise_if_exists",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"HdfsTarget",
")",
":",
"path",
"=",
"path",
".",
"path",
"if",
"raise_if_exists",
"and",
"self",
".",
"fs",
".",
"exists",... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | HdfsTarget.move | Alias for ``rename()`` | luigi/contrib/hdfs/target.py | def move(self, path, raise_if_exists=False):
"""
Alias for ``rename()``
"""
self.rename(path, raise_if_exists=raise_if_exists) | def move(self, path, raise_if_exists=False):
"""
Alias for ``rename()``
"""
self.rename(path, raise_if_exists=raise_if_exists) | [
"Alias",
"for",
"rename",
"()"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/target.py#L134-L138 | [
"def",
"move",
"(",
"self",
",",
"path",
",",
"raise_if_exists",
"=",
"False",
")",
":",
"self",
".",
"rename",
"(",
"path",
",",
"raise_if_exists",
"=",
"raise_if_exists",
")"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | HdfsTarget.is_writable | Currently only works with hadoopcli | luigi/contrib/hdfs/target.py | def is_writable(self):
"""
Currently only works with hadoopcli
"""
if "/" in self.path:
# example path: /log/ap/2013-01-17/00
parts = self.path.split("/")
# start with the full path and then up the tree until we can check
length = len(parts... | def is_writable(self):
"""
Currently only works with hadoopcli
"""
if "/" in self.path:
# example path: /log/ap/2013-01-17/00
parts = self.path.split("/")
# start with the full path and then up the tree until we can check
length = len(parts... | [
"Currently",
"only",
"works",
"with",
"hadoopcli"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/target.py#L158-L178 | [
"def",
"is_writable",
"(",
"self",
")",
":",
"if",
"\"/\"",
"in",
"self",
".",
"path",
":",
"# example path: /log/ap/2013-01-17/00",
"parts",
"=",
"self",
".",
"path",
".",
"split",
"(",
"\"/\"",
")",
"# start with the full path and then up the tree until we can check... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _partition_tasks | Takes a worker and sorts out tasks based on their status.
Still_pending_not_ext is only used to get upstream_failure, upstream_missing_dependency and run_by_other_worker | luigi/execution_summary.py | def _partition_tasks(worker):
"""
Takes a worker and sorts out tasks based on their status.
Still_pending_not_ext is only used to get upstream_failure, upstream_missing_dependency and run_by_other_worker
"""
task_history = worker._add_task_history
pending_tasks = {task for(task, status, ext) in ... | def _partition_tasks(worker):
"""
Takes a worker and sorts out tasks based on their status.
Still_pending_not_ext is only used to get upstream_failure, upstream_missing_dependency and run_by_other_worker
"""
task_history = worker._add_task_history
pending_tasks = {task for(task, status, ext) in ... | [
"Takes",
"a",
"worker",
"and",
"sorts",
"out",
"tasks",
"based",
"on",
"their",
"status",
".",
"Still_pending_not_ext",
"is",
"only",
"used",
"to",
"get",
"upstream_failure",
"upstream_missing_dependency",
"and",
"run_by_other_worker"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L91-L115 | [
"def",
"_partition_tasks",
"(",
"worker",
")",
":",
"task_history",
"=",
"worker",
".",
"_add_task_history",
"pending_tasks",
"=",
"{",
"task",
"for",
"(",
"task",
",",
"status",
",",
"ext",
")",
"in",
"task_history",
"if",
"status",
"==",
"'PENDING'",
"}",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _populate_unknown_statuses | Add the "upstream_*" and "not_run" statuses my mutating set_tasks. | luigi/execution_summary.py | def _populate_unknown_statuses(set_tasks):
"""
Add the "upstream_*" and "not_run" statuses my mutating set_tasks.
"""
visited = set()
for task in set_tasks["still_pending_not_ext"]:
_depth_first_search(set_tasks, task, visited) | def _populate_unknown_statuses(set_tasks):
"""
Add the "upstream_*" and "not_run" statuses my mutating set_tasks.
"""
visited = set()
for task in set_tasks["still_pending_not_ext"]:
_depth_first_search(set_tasks, task, visited) | [
"Add",
"the",
"upstream_",
"*",
"and",
"not_run",
"statuses",
"my",
"mutating",
"set_tasks",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L125-L131 | [
"def",
"_populate_unknown_statuses",
"(",
"set_tasks",
")",
":",
"visited",
"=",
"set",
"(",
")",
"for",
"task",
"in",
"set_tasks",
"[",
"\"still_pending_not_ext\"",
"]",
":",
"_depth_first_search",
"(",
"set_tasks",
",",
"task",
",",
"visited",
")"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _depth_first_search | This dfs checks why tasks are still pending. | luigi/execution_summary.py | def _depth_first_search(set_tasks, current_task, visited):
"""
This dfs checks why tasks are still pending.
"""
visited.add(current_task)
if current_task in set_tasks["still_pending_not_ext"]:
upstream_failure = False
upstream_missing_dependency = False
upstream_run_by_other_... | def _depth_first_search(set_tasks, current_task, visited):
"""
This dfs checks why tasks are still pending.
"""
visited.add(current_task)
if current_task in set_tasks["still_pending_not_ext"]:
upstream_failure = False
upstream_missing_dependency = False
upstream_run_by_other_... | [
"This",
"dfs",
"checks",
"why",
"tasks",
"are",
"still",
"pending",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L134-L162 | [
"def",
"_depth_first_search",
"(",
"set_tasks",
",",
"current_task",
",",
"visited",
")",
":",
"visited",
".",
"add",
"(",
"current_task",
")",
"if",
"current_task",
"in",
"set_tasks",
"[",
"\"still_pending_not_ext\"",
"]",
":",
"upstream_failure",
"=",
"False",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _get_str | This returns a string for each status | luigi/execution_summary.py | def _get_str(task_dict, extra_indent):
"""
This returns a string for each status
"""
summary_length = execution_summary().summary_length
lines = []
task_names = sorted(task_dict.keys())
for task_family in task_names:
tasks = task_dict[task_family]
tasks = sorted(tasks, key=l... | def _get_str(task_dict, extra_indent):
"""
This returns a string for each status
"""
summary_length = execution_summary().summary_length
lines = []
task_names = sorted(task_dict.keys())
for task_family in task_names:
tasks = task_dict[task_family]
tasks = sorted(tasks, key=l... | [
"This",
"returns",
"a",
"string",
"for",
"each",
"status"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L165-L222 | [
"def",
"_get_str",
"(",
"task_dict",
",",
"extra_indent",
")",
":",
"summary_length",
"=",
"execution_summary",
"(",
")",
".",
"summary_length",
"lines",
"=",
"[",
"]",
"task_names",
"=",
"sorted",
"(",
"task_dict",
".",
"keys",
"(",
")",
")",
"for",
"task... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _ranging_attributes | Checks if there is a continuous range | luigi/execution_summary.py | def _ranging_attributes(attributes, param_class):
"""
Checks if there is a continuous range
"""
next_attributes = {param_class.next_in_enumeration(attribute) for attribute in attributes}
in_first = attributes.difference(next_attributes)
in_second = next_attributes.difference(attributes)
if l... | def _ranging_attributes(attributes, param_class):
"""
Checks if there is a continuous range
"""
next_attributes = {param_class.next_in_enumeration(attribute) for attribute in attributes}
in_first = attributes.difference(next_attributes)
in_second = next_attributes.difference(attributes)
if l... | [
"Checks",
"if",
"there",
"is",
"a",
"continuous",
"range"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L257-L268 | [
"def",
"_ranging_attributes",
"(",
"attributes",
",",
"param_class",
")",
":",
"next_attributes",
"=",
"{",
"param_class",
".",
"next_in_enumeration",
"(",
"attribute",
")",
"for",
"attribute",
"in",
"attributes",
"}",
"in_first",
"=",
"attributes",
".",
"differen... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _get_comments | Get the human readable comments and quantities for the task types. | luigi/execution_summary.py | def _get_comments(group_tasks):
"""
Get the human readable comments and quantities for the task types.
"""
comments = {}
for status, human in _COMMENTS:
num_tasks = _get_number_of_tasks_for(status, group_tasks)
if num_tasks:
space = " " if status in _PENDING_SUB_STATUS... | def _get_comments(group_tasks):
"""
Get the human readable comments and quantities for the task types.
"""
comments = {}
for status, human in _COMMENTS:
num_tasks = _get_number_of_tasks_for(status, group_tasks)
if num_tasks:
space = " " if status in _PENDING_SUB_STATUS... | [
"Get",
"the",
"human",
"readable",
"comments",
"and",
"quantities",
"for",
"the",
"task",
"types",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L301-L314 | [
"def",
"_get_comments",
"(",
"group_tasks",
")",
":",
"comments",
"=",
"{",
"}",
"for",
"status",
",",
"human",
"in",
"_COMMENTS",
":",
"num_tasks",
"=",
"_get_number_of_tasks_for",
"(",
"status",
",",
"group_tasks",
")",
"if",
"num_tasks",
":",
"space",
"="... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _get_run_by_other_worker | This returns a set of the tasks that are being run by other worker | luigi/execution_summary.py | def _get_run_by_other_worker(worker):
"""
This returns a set of the tasks that are being run by other worker
"""
task_sets = _get_external_workers(worker).values()
return functools.reduce(lambda a, b: a | b, task_sets, set()) | def _get_run_by_other_worker(worker):
"""
This returns a set of the tasks that are being run by other worker
"""
task_sets = _get_external_workers(worker).values()
return functools.reduce(lambda a, b: a | b, task_sets, set()) | [
"This",
"returns",
"a",
"set",
"of",
"the",
"tasks",
"that",
"are",
"being",
"run",
"by",
"other",
"worker"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L350-L355 | [
"def",
"_get_run_by_other_worker",
"(",
"worker",
")",
":",
"task_sets",
"=",
"_get_external_workers",
"(",
"worker",
")",
".",
"values",
"(",
")",
"return",
"functools",
".",
"reduce",
"(",
"lambda",
"a",
",",
"b",
":",
"a",
"|",
"b",
",",
"task_sets",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _get_external_workers | This returns a dict with a set of tasks for all of the other workers | luigi/execution_summary.py | def _get_external_workers(worker):
"""
This returns a dict with a set of tasks for all of the other workers
"""
worker_that_blocked_task = collections.defaultdict(set)
get_work_response_history = worker._get_work_response_history
for get_work_response in get_work_response_history:
if get... | def _get_external_workers(worker):
"""
This returns a dict with a set of tasks for all of the other workers
"""
worker_that_blocked_task = collections.defaultdict(set)
get_work_response_history = worker._get_work_response_history
for get_work_response in get_work_response_history:
if get... | [
"This",
"returns",
"a",
"dict",
"with",
"a",
"set",
"of",
"tasks",
"for",
"all",
"of",
"the",
"other",
"workers"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L358-L373 | [
"def",
"_get_external_workers",
"(",
"worker",
")",
":",
"worker_that_blocked_task",
"=",
"collections",
".",
"defaultdict",
"(",
"set",
")",
"get_work_response_history",
"=",
"worker",
".",
"_get_work_response_history",
"for",
"get_work_response",
"in",
"get_work_respons... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _group_tasks_by_name_and_status | Takes a dictionary with sets of tasks grouped by their status and
returns a dictionary with dictionaries with an array of tasks grouped by
their status and task name | luigi/execution_summary.py | def _group_tasks_by_name_and_status(task_dict):
"""
Takes a dictionary with sets of tasks grouped by their status and
returns a dictionary with dictionaries with an array of tasks grouped by
their status and task name
"""
group_status = {}
for task in task_dict:
if task.task_family n... | def _group_tasks_by_name_and_status(task_dict):
"""
Takes a dictionary with sets of tasks grouped by their status and
returns a dictionary with dictionaries with an array of tasks grouped by
their status and task name
"""
group_status = {}
for task in task_dict:
if task.task_family n... | [
"Takes",
"a",
"dictionary",
"with",
"sets",
"of",
"tasks",
"grouped",
"by",
"their",
"status",
"and",
"returns",
"a",
"dictionary",
"with",
"dictionaries",
"with",
"an",
"array",
"of",
"tasks",
"grouped",
"by",
"their",
"status",
"and",
"task",
"name"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L376-L387 | [
"def",
"_group_tasks_by_name_and_status",
"(",
"task_dict",
")",
":",
"group_status",
"=",
"{",
"}",
"for",
"task",
"in",
"task_dict",
":",
"if",
"task",
".",
"task_family",
"not",
"in",
"group_status",
":",
"group_status",
"[",
"task",
".",
"task_family",
"]"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _tasks_status | Given a grouped set of tasks, returns a LuigiStatusCode | luigi/execution_summary.py | def _tasks_status(set_tasks):
"""
Given a grouped set of tasks, returns a LuigiStatusCode
"""
if set_tasks["ever_failed"]:
if not set_tasks["failed"]:
return LuigiStatusCode.SUCCESS_WITH_RETRY
else:
if set_tasks["scheduling_error"]:
return LuigiSta... | def _tasks_status(set_tasks):
"""
Given a grouped set of tasks, returns a LuigiStatusCode
"""
if set_tasks["ever_failed"]:
if not set_tasks["failed"]:
return LuigiStatusCode.SUCCESS_WITH_RETRY
else:
if set_tasks["scheduling_error"]:
return LuigiSta... | [
"Given",
"a",
"grouped",
"set",
"of",
"tasks",
"returns",
"a",
"LuigiStatusCode"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L450-L468 | [
"def",
"_tasks_status",
"(",
"set_tasks",
")",
":",
"if",
"set_tasks",
"[",
"\"ever_failed\"",
"]",
":",
"if",
"not",
"set_tasks",
"[",
"\"failed\"",
"]",
":",
"return",
"LuigiStatusCode",
".",
"SUCCESS_WITH_RETRY",
"else",
":",
"if",
"set_tasks",
"[",
"\"sche... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | task_id_str | Returns a canonical string used to identify a particular task
:param task_family: The task family (class name) of the task
:param params: a dict mapping parameter names to their serialized values
:return: A unique, shortened identifier corresponding to the family and params | luigi/task.py | def task_id_str(task_family, params):
"""
Returns a canonical string used to identify a particular task
:param task_family: The task family (class name) of the task
:param params: a dict mapping parameter names to their serialized values
:return: A unique, shortened identifier corresponding to the ... | def task_id_str(task_family, params):
"""
Returns a canonical string used to identify a particular task
:param task_family: The task family (class name) of the task
:param params: a dict mapping parameter names to their serialized values
:return: A unique, shortened identifier corresponding to the ... | [
"Returns",
"a",
"canonical",
"string",
"used",
"to",
"identify",
"a",
"particular",
"task"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task.py#L120-L137 | [
"def",
"task_id_str",
"(",
"task_family",
",",
"params",
")",
":",
"# task_id is a concatenation of task family, the first values of the first 3 parameters",
"# sorted by parameter name and a md5hash of the family/parameters as a cananocalised json.",
"param_str",
"=",
"json",
".",
"dump... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | externalize | Returns an externalized version of a Task. You may both pass an
instantiated task object or a task class. Some examples:
.. code-block:: python
class RequiringTask(luigi.Task):
def requires(self):
task_object = self.clone(MyTask)
return externalize(task_obje... | luigi/task.py | def externalize(taskclass_or_taskobject):
"""
Returns an externalized version of a Task. You may both pass an
instantiated task object or a task class. Some examples:
.. code-block:: python
class RequiringTask(luigi.Task):
def requires(self):
task_object = self.clon... | def externalize(taskclass_or_taskobject):
"""
Returns an externalized version of a Task. You may both pass an
instantiated task object or a task class. Some examples:
.. code-block:: python
class RequiringTask(luigi.Task):
def requires(self):
task_object = self.clon... | [
"Returns",
"an",
"externalized",
"version",
"of",
"a",
"Task",
".",
"You",
"may",
"both",
"pass",
"an",
"instantiated",
"task",
"object",
"or",
"a",
"task",
"class",
".",
"Some",
"examples",
":"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task.py#L757-L817 | [
"def",
"externalize",
"(",
"taskclass_or_taskobject",
")",
":",
"# Seems like with python < 3.3 copy.copy can't copy classes",
"# and objects with specified metaclass http://bugs.python.org/issue11480",
"compatible_copy",
"=",
"copy",
".",
"copy",
"if",
"six",
".",
"PY3",
"else",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | getpaths | Maps all Tasks in a structured data object to their .output(). | luigi/task.py | def getpaths(struct):
"""
Maps all Tasks in a structured data object to their .output().
"""
if isinstance(struct, Task):
return struct.output()
elif isinstance(struct, dict):
return struct.__class__((k, getpaths(v)) for k, v in six.iteritems(struct))
elif isinstance(struct, (lis... | def getpaths(struct):
"""
Maps all Tasks in a structured data object to their .output().
"""
if isinstance(struct, Task):
return struct.output()
elif isinstance(struct, dict):
return struct.__class__((k, getpaths(v)) for k, v in six.iteritems(struct))
elif isinstance(struct, (lis... | [
"Maps",
"all",
"Tasks",
"in",
"a",
"structured",
"data",
"object",
"to",
"their",
".",
"output",
"()",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task.py#L838-L853 | [
"def",
"getpaths",
"(",
"struct",
")",
":",
"if",
"isinstance",
"(",
"struct",
",",
"Task",
")",
":",
"return",
"struct",
".",
"output",
"(",
")",
"elif",
"isinstance",
"(",
"struct",
",",
"dict",
")",
":",
"return",
"struct",
".",
"__class__",
"(",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | flatten | Creates a flat list of all all items in structured output (dicts, lists, items):
.. code-block:: python
>>> sorted(flatten({'a': 'foo', 'b': 'bar'}))
['bar', 'foo']
>>> sorted(flatten(['foo', ['bar', 'troll']]))
['bar', 'foo', 'troll']
>>> flatten('foo')
['foo']
... | luigi/task.py | def flatten(struct):
"""
Creates a flat list of all all items in structured output (dicts, lists, items):
.. code-block:: python
>>> sorted(flatten({'a': 'foo', 'b': 'bar'}))
['bar', 'foo']
>>> sorted(flatten(['foo', ['bar', 'troll']]))
['bar', 'foo', 'troll']
>>> f... | def flatten(struct):
"""
Creates a flat list of all all items in structured output (dicts, lists, items):
.. code-block:: python
>>> sorted(flatten({'a': 'foo', 'b': 'bar'}))
['bar', 'foo']
>>> sorted(flatten(['foo', ['bar', 'troll']]))
['bar', 'foo', 'troll']
>>> f... | [
"Creates",
"a",
"flat",
"list",
"of",
"all",
"all",
"items",
"in",
"structured",
"output",
"(",
"dicts",
"lists",
"items",
")",
":"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task.py#L856-L889 | [
"def",
"flatten",
"(",
"struct",
")",
":",
"if",
"struct",
"is",
"None",
":",
"return",
"[",
"]",
"flat",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"struct",
",",
"dict",
")",
":",
"for",
"_",
",",
"result",
"in",
"six",
".",
"iteritems",
"(",
"str... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | flatten_output | Lists all output targets by recursively walking output-less (wrapper) tasks.
FIXME order consistently. | luigi/task.py | def flatten_output(task):
"""
Lists all output targets by recursively walking output-less (wrapper) tasks.
FIXME order consistently.
"""
r = flatten(task.output())
if not r:
for dep in flatten(task.requires()):
r += flatten_output(dep)
return r | def flatten_output(task):
"""
Lists all output targets by recursively walking output-less (wrapper) tasks.
FIXME order consistently.
"""
r = flatten(task.output())
if not r:
for dep in flatten(task.requires()):
r += flatten_output(dep)
return r | [
"Lists",
"all",
"output",
"targets",
"by",
"recursively",
"walking",
"output",
"-",
"less",
"(",
"wrapper",
")",
"tasks",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task.py#L892-L902 | [
"def",
"flatten_output",
"(",
"task",
")",
":",
"r",
"=",
"flatten",
"(",
"task",
".",
"output",
"(",
")",
")",
"if",
"not",
"r",
":",
"for",
"dep",
"in",
"flatten",
"(",
"task",
".",
"requires",
"(",
")",
")",
":",
"r",
"+=",
"flatten_output",
"... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.get_bite | If Luigi has forked, we have a different PID, and need to reconnect. | luigi/contrib/hdfs/snakebite_client.py | def get_bite(self):
"""
If Luigi has forked, we have a different PID, and need to reconnect.
"""
config = hdfs_config.hdfs()
if self.pid != os.getpid() or not self._bite:
client_kwargs = dict(filter(
lambda k_v: k_v[1] is not None and k_v[1] != '', six... | def get_bite(self):
"""
If Luigi has forked, we have a different PID, and need to reconnect.
"""
config = hdfs_config.hdfs()
if self.pid != os.getpid() or not self._bite:
client_kwargs = dict(filter(
lambda k_v: k_v[1] is not None and k_v[1] != '', six... | [
"If",
"Luigi",
"has",
"forked",
"we",
"have",
"a",
"different",
"PID",
"and",
"need",
"to",
"reconnect",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L58-L81 | [
"def",
"get_bite",
"(",
"self",
")",
":",
"config",
"=",
"hdfs_config",
".",
"hdfs",
"(",
")",
"if",
"self",
".",
"pid",
"!=",
"os",
".",
"getpid",
"(",
")",
"or",
"not",
"self",
".",
"_bite",
":",
"client_kwargs",
"=",
"dict",
"(",
"filter",
"(",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.move | Use snakebite.rename, if available.
:param path: source file(s)
:type path: either a string or sequence of strings
:param dest: destination file (single input) or directory (multiple)
:type dest: string
:return: list of renamed items | luigi/contrib/hdfs/snakebite_client.py | def move(self, path, dest):
"""
Use snakebite.rename, if available.
:param path: source file(s)
:type path: either a string or sequence of strings
:param dest: destination file (single input) or directory (multiple)
:type dest: string
:return: list of renamed ite... | def move(self, path, dest):
"""
Use snakebite.rename, if available.
:param path: source file(s)
:type path: either a string or sequence of strings
:param dest: destination file (single input) or directory (multiple)
:type dest: string
:return: list of renamed ite... | [
"Use",
"snakebite",
".",
"rename",
"if",
"available",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L93-L108 | [
"def",
"move",
"(",
"self",
",",
"path",
",",
"dest",
")",
":",
"parts",
"=",
"dest",
".",
"rstrip",
"(",
"'/'",
")",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"parts",
")",
">",
"1",
":",
"dir_path",
"=",
"'/'",
".",
"join",
"(",
"par... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.rename_dont_move | Use snakebite.rename_dont_move, if available.
:param path: source path (single input)
:type path: string
:param dest: destination path
:type dest: string
:return: True if succeeded
:raises: snakebite.errors.FileAlreadyExistsException | luigi/contrib/hdfs/snakebite_client.py | def rename_dont_move(self, path, dest):
"""
Use snakebite.rename_dont_move, if available.
:param path: source path (single input)
:type path: string
:param dest: destination path
:type dest: string
:return: True if succeeded
:raises: snakebite.errors.File... | def rename_dont_move(self, path, dest):
"""
Use snakebite.rename_dont_move, if available.
:param path: source path (single input)
:type path: string
:param dest: destination path
:type dest: string
:return: True if succeeded
:raises: snakebite.errors.File... | [
"Use",
"snakebite",
".",
"rename_dont_move",
"if",
"available",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L110-L126 | [
"def",
"rename_dont_move",
"(",
"self",
",",
"path",
",",
"dest",
")",
":",
"from",
"snakebite",
".",
"errors",
"import",
"FileAlreadyExistsException",
"try",
":",
"self",
".",
"get_bite",
"(",
")",
".",
"rename2",
"(",
"path",
",",
"dest",
",",
"overwrite... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.remove | Use snakebite.delete, if available.
:param path: delete-able file(s) or directory(ies)
:type path: either a string or a sequence of strings
:param recursive: delete directories trees like \\*nix: rm -r
:type recursive: boolean, default is True
:param skip_trash: do or don't move... | luigi/contrib/hdfs/snakebite_client.py | def remove(self, path, recursive=True, skip_trash=False):
"""
Use snakebite.delete, if available.
:param path: delete-able file(s) or directory(ies)
:type path: either a string or a sequence of strings
:param recursive: delete directories trees like \\*nix: rm -r
:type r... | def remove(self, path, recursive=True, skip_trash=False):
"""
Use snakebite.delete, if available.
:param path: delete-able file(s) or directory(ies)
:type path: either a string or a sequence of strings
:param recursive: delete directories trees like \\*nix: rm -r
:type r... | [
"Use",
"snakebite",
".",
"delete",
"if",
"available",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L128-L140 | [
"def",
"remove",
"(",
"self",
",",
"path",
",",
"recursive",
"=",
"True",
",",
"skip_trash",
"=",
"False",
")",
":",
"return",
"list",
"(",
"self",
".",
"get_bite",
"(",
")",
".",
"delete",
"(",
"self",
".",
"list_path",
"(",
"path",
")",
",",
"rec... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.chmod | Use snakebite.chmod, if available.
:param path: update-able file(s)
:type path: either a string or sequence of strings
:param permissions: \\*nix style permission number
:type permissions: octal
:param recursive: change just listed entry(ies) or all in directories
:type ... | luigi/contrib/hdfs/snakebite_client.py | def chmod(self, path, permissions, recursive=False):
"""
Use snakebite.chmod, if available.
:param path: update-able file(s)
:type path: either a string or sequence of strings
:param permissions: \\*nix style permission number
:type permissions: octal
:param recu... | def chmod(self, path, permissions, recursive=False):
"""
Use snakebite.chmod, if available.
:param path: update-able file(s)
:type path: either a string or sequence of strings
:param permissions: \\*nix style permission number
:type permissions: octal
:param recu... | [
"Use",
"snakebite",
".",
"chmod",
"if",
"available",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L142-L157 | [
"def",
"chmod",
"(",
"self",
",",
"path",
",",
"permissions",
",",
"recursive",
"=",
"False",
")",
":",
"if",
"type",
"(",
"permissions",
")",
"==",
"str",
":",
"permissions",
"=",
"int",
"(",
"permissions",
",",
"8",
")",
"return",
"list",
"(",
"sel... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.chown | Use snakebite.chown/chgrp, if available.
One of owner or group must be set. Just setting group calls chgrp.
:param path: update-able file(s)
:type path: either a string or sequence of strings
:param owner: new owner, can be blank
:type owner: string
:param group: new gr... | luigi/contrib/hdfs/snakebite_client.py | def chown(self, path, owner, group, recursive=False):
"""
Use snakebite.chown/chgrp, if available.
One of owner or group must be set. Just setting group calls chgrp.
:param path: update-able file(s)
:type path: either a string or sequence of strings
:param owner: new ow... | def chown(self, path, owner, group, recursive=False):
"""
Use snakebite.chown/chgrp, if available.
One of owner or group must be set. Just setting group calls chgrp.
:param path: update-able file(s)
:type path: either a string or sequence of strings
:param owner: new ow... | [
"Use",
"snakebite",
".",
"chown",
"/",
"chgrp",
"if",
"available",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L159-L181 | [
"def",
"chown",
"(",
"self",
",",
"path",
",",
"owner",
",",
"group",
",",
"recursive",
"=",
"False",
")",
":",
"bite",
"=",
"self",
".",
"get_bite",
"(",
")",
"if",
"owner",
":",
"if",
"group",
":",
"return",
"all",
"(",
"bite",
".",
"chown",
"(... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.count | Use snakebite.count, if available.
:param path: directory to count the contents of
:type path: string
:return: dictionary with content_size, dir_count and file_count keys | luigi/contrib/hdfs/snakebite_client.py | def count(self, path):
"""
Use snakebite.count, if available.
:param path: directory to count the contents of
:type path: string
:return: dictionary with content_size, dir_count and file_count keys
"""
try:
res = self.get_bite().count(self.list_path(p... | def count(self, path):
"""
Use snakebite.count, if available.
:param path: directory to count the contents of
:type path: string
:return: dictionary with content_size, dir_count and file_count keys
"""
try:
res = self.get_bite().count(self.list_path(p... | [
"Use",
"snakebite",
".",
"count",
"if",
"available",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L183-L199 | [
"def",
"count",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"get_bite",
"(",
")",
".",
"count",
"(",
"self",
".",
"list_path",
"(",
"path",
")",
")",
".",
"next",
"(",
")",
"dir_count",
"=",
"res",
"[",
"'directoryCou... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.get | Use snakebite.copyToLocal, if available.
:param path: HDFS file
:type path: string
:param local_destination: path on the system running Luigi
:type local_destination: string | luigi/contrib/hdfs/snakebite_client.py | def get(self, path, local_destination):
"""
Use snakebite.copyToLocal, if available.
:param path: HDFS file
:type path: string
:param local_destination: path on the system running Luigi
:type local_destination: string
"""
return list(self.get_bite().copyT... | def get(self, path, local_destination):
"""
Use snakebite.copyToLocal, if available.
:param path: HDFS file
:type path: string
:param local_destination: path on the system running Luigi
:type local_destination: string
"""
return list(self.get_bite().copyT... | [
"Use",
"snakebite",
".",
"copyToLocal",
"if",
"available",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L213-L223 | [
"def",
"get",
"(",
"self",
",",
"path",
",",
"local_destination",
")",
":",
"return",
"list",
"(",
"self",
".",
"get_bite",
"(",
")",
".",
"copyToLocal",
"(",
"self",
".",
"list_path",
"(",
"path",
")",
",",
"local_destination",
")",
")"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.get_merge | Using snakebite getmerge to implement this.
:param path: HDFS directory
:param local_destination: path on the system running Luigi
:return: merge of the directory | luigi/contrib/hdfs/snakebite_client.py | def get_merge(self, path, local_destination):
"""
Using snakebite getmerge to implement this.
:param path: HDFS directory
:param local_destination: path on the system running Luigi
:return: merge of the directory
"""
return list(self.get_bite().getmerge(path=path,... | def get_merge(self, path, local_destination):
"""
Using snakebite getmerge to implement this.
:param path: HDFS directory
:param local_destination: path on the system running Luigi
:return: merge of the directory
"""
return list(self.get_bite().getmerge(path=path,... | [
"Using",
"snakebite",
"getmerge",
"to",
"implement",
"this",
".",
":",
"param",
"path",
":",
"HDFS",
"directory",
":",
"param",
"local_destination",
":",
"path",
"on",
"the",
"system",
"running",
"Luigi",
":",
"return",
":",
"merge",
"of",
"the",
"directory"... | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L225-L232 | [
"def",
"get_merge",
"(",
"self",
",",
"path",
",",
"local_destination",
")",
":",
"return",
"list",
"(",
"self",
".",
"get_bite",
"(",
")",
".",
"getmerge",
"(",
"path",
"=",
"path",
",",
"dst",
"=",
"local_destination",
")",
")"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.mkdir | Use snakebite.mkdir, if available.
Snakebite's mkdir method allows control over full path creation, so by
default, tell it to build a full path to work like ``hadoop fs -mkdir``.
:param path: HDFS path to create
:type path: string
:param parents: create any missing parent direc... | luigi/contrib/hdfs/snakebite_client.py | def mkdir(self, path, parents=True, mode=0o755, raise_if_exists=False):
"""
Use snakebite.mkdir, if available.
Snakebite's mkdir method allows control over full path creation, so by
default, tell it to build a full path to work like ``hadoop fs -mkdir``.
:param path: HDFS path ... | def mkdir(self, path, parents=True, mode=0o755, raise_if_exists=False):
"""
Use snakebite.mkdir, if available.
Snakebite's mkdir method allows control over full path creation, so by
default, tell it to build a full path to work like ``hadoop fs -mkdir``.
:param path: HDFS path ... | [
"Use",
"snakebite",
".",
"mkdir",
"if",
"available",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L234-L252 | [
"def",
"mkdir",
"(",
"self",
",",
"path",
",",
"parents",
"=",
"True",
",",
"mode",
"=",
"0o755",
",",
"raise_if_exists",
"=",
"False",
")",
":",
"result",
"=",
"list",
"(",
"self",
".",
"get_bite",
"(",
")",
".",
"mkdir",
"(",
"self",
".",
"list_p... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | SnakebiteHdfsClient.listdir | Use snakebite.ls to get the list of items in a directory.
:param path: the directory to list
:type path: string
:param ignore_directories: if True, do not yield directory entries
:type ignore_directories: boolean, default is False
:param ignore_files: if True, do not yield file ... | luigi/contrib/hdfs/snakebite_client.py | def listdir(self, path, ignore_directories=False, ignore_files=False,
include_size=False, include_type=False, include_time=False,
recursive=False):
"""
Use snakebite.ls to get the list of items in a directory.
:param path: the directory to list
:type path... | def listdir(self, path, ignore_directories=False, ignore_files=False,
include_size=False, include_type=False, include_time=False,
recursive=False):
"""
Use snakebite.ls to get the list of items in a directory.
:param path: the directory to list
:type path... | [
"Use",
"snakebite",
".",
"ls",
"to",
"get",
"the",
"list",
"of",
"items",
"in",
"a",
"directory",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hdfs/snakebite_client.py#L254-L293 | [
"def",
"listdir",
"(",
"self",
",",
"path",
",",
"ignore_directories",
"=",
"False",
",",
"ignore_files",
"=",
"False",
",",
"include_size",
"=",
"False",
",",
"include_type",
"=",
"False",
",",
"include_time",
"=",
"False",
",",
"recursive",
"=",
"False",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | BaseParser.instance | Singleton getter | luigi/configuration/base_parser.py | def instance(cls, *args, **kwargs):
""" Singleton getter """
if cls._instance is None:
cls._instance = cls(*args, **kwargs)
loaded = cls._instance.reload()
logging.getLogger('luigi-interface').info('Loaded %r', loaded)
return cls._instance | def instance(cls, *args, **kwargs):
""" Singleton getter """
if cls._instance is None:
cls._instance = cls(*args, **kwargs)
loaded = cls._instance.reload()
logging.getLogger('luigi-interface').info('Loaded %r', loaded)
return cls._instance | [
"Singleton",
"getter"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/configuration/base_parser.py#L25-L32 | [
"def",
"instance",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"cls",
".",
"_instance",
"is",
"None",
":",
"cls",
".",
"_instance",
"=",
"cls",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"loaded",
"=",
"cls",
"."... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | load_task | Imports task dynamically given a module and a task name. | luigi/task_register.py | def load_task(module, task_name, params_str):
"""
Imports task dynamically given a module and a task name.
"""
if module is not None:
__import__(module)
task_cls = Register.get_task_cls(task_name)
return task_cls.from_str_params(params_str) | def load_task(module, task_name, params_str):
"""
Imports task dynamically given a module and a task name.
"""
if module is not None:
__import__(module)
task_cls = Register.get_task_cls(task_name)
return task_cls.from_str_params(params_str) | [
"Imports",
"task",
"dynamically",
"given",
"a",
"module",
"and",
"a",
"task",
"name",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task_register.py#L246-L253 | [
"def",
"load_task",
"(",
"module",
",",
"task_name",
",",
"params_str",
")",
":",
"if",
"module",
"is",
"not",
"None",
":",
"__import__",
"(",
"module",
")",
"task_cls",
"=",
"Register",
".",
"get_task_cls",
"(",
"task_name",
")",
"return",
"task_cls",
"."... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Register.task_family | Internal note: This function will be deleted soon. | luigi/task_register.py | def task_family(cls):
"""
Internal note: This function will be deleted soon.
"""
if not cls.get_task_namespace():
return cls.__name__
else:
return "{}.{}".format(cls.get_task_namespace(), cls.__name__) | def task_family(cls):
"""
Internal note: This function will be deleted soon.
"""
if not cls.get_task_namespace():
return cls.__name__
else:
return "{}.{}".format(cls.get_task_namespace(), cls.__name__) | [
"Internal",
"note",
":",
"This",
"function",
"will",
"be",
"deleted",
"soon",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task_register.py#L118-L125 | [
"def",
"task_family",
"(",
"cls",
")",
":",
"if",
"not",
"cls",
".",
"get_task_namespace",
"(",
")",
":",
"return",
"cls",
".",
"__name__",
"else",
":",
"return",
"\"{}.{}\"",
".",
"format",
"(",
"cls",
".",
"get_task_namespace",
"(",
")",
",",
"cls",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Register._get_reg | Return all of the registered classes.
:return: an ``dict`` of task_family -> class | luigi/task_register.py | def _get_reg(cls):
"""Return all of the registered classes.
:return: an ``dict`` of task_family -> class
"""
# We have to do this on-demand in case task names have changed later
reg = dict()
for task_cls in cls._reg:
if not task_cls._visible_in_registry:
... | def _get_reg(cls):
"""Return all of the registered classes.
:return: an ``dict`` of task_family -> class
"""
# We have to do this on-demand in case task names have changed later
reg = dict()
for task_cls in cls._reg:
if not task_cls._visible_in_registry:
... | [
"Return",
"all",
"of",
"the",
"registered",
"classes",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task_register.py#L128-L150 | [
"def",
"_get_reg",
"(",
"cls",
")",
":",
"# We have to do this on-demand in case task names have changed later",
"reg",
"=",
"dict",
"(",
")",
"for",
"task_cls",
"in",
"cls",
".",
"_reg",
":",
"if",
"not",
"task_cls",
".",
"_visible_in_registry",
":",
"continue",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Register._set_reg | The writing complement of _get_reg | luigi/task_register.py | def _set_reg(cls, reg):
"""The writing complement of _get_reg
"""
cls._reg = [task_cls for task_cls in reg.values() if task_cls is not cls.AMBIGUOUS_CLASS] | def _set_reg(cls, reg):
"""The writing complement of _get_reg
"""
cls._reg = [task_cls for task_cls in reg.values() if task_cls is not cls.AMBIGUOUS_CLASS] | [
"The",
"writing",
"complement",
"of",
"_get_reg"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task_register.py#L153-L156 | [
"def",
"_set_reg",
"(",
"cls",
",",
"reg",
")",
":",
"cls",
".",
"_reg",
"=",
"[",
"task_cls",
"for",
"task_cls",
"in",
"reg",
".",
"values",
"(",
")",
"if",
"task_cls",
"is",
"not",
"cls",
".",
"AMBIGUOUS_CLASS",
"]"
] | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Register.get_task_cls | Returns an unambiguous class or raises an exception. | luigi/task_register.py | def get_task_cls(cls, name):
"""
Returns an unambiguous class or raises an exception.
"""
task_cls = cls._get_reg().get(name)
if not task_cls:
raise TaskClassNotFoundException(cls._missing_task_msg(name))
if task_cls == cls.AMBIGUOUS_CLASS:
raise ... | def get_task_cls(cls, name):
"""
Returns an unambiguous class or raises an exception.
"""
task_cls = cls._get_reg().get(name)
if not task_cls:
raise TaskClassNotFoundException(cls._missing_task_msg(name))
if task_cls == cls.AMBIGUOUS_CLASS:
raise ... | [
"Returns",
"an",
"unambiguous",
"class",
"or",
"raises",
"an",
"exception",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task_register.py#L173-L183 | [
"def",
"get_task_cls",
"(",
"cls",
",",
"name",
")",
":",
"task_cls",
"=",
"cls",
".",
"_get_reg",
"(",
")",
".",
"get",
"(",
"name",
")",
"if",
"not",
"task_cls",
":",
"raise",
"TaskClassNotFoundException",
"(",
"cls",
".",
"_missing_task_msg",
"(",
"na... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Register.get_all_params | Compiles and returns all parameters for all :py:class:`Task`.
:return: a generator of tuples (TODO: we should make this more elegant) | luigi/task_register.py | def get_all_params(cls):
"""
Compiles and returns all parameters for all :py:class:`Task`.
:return: a generator of tuples (TODO: we should make this more elegant)
"""
for task_name, task_cls in six.iteritems(cls._get_reg()):
if task_cls == cls.AMBIGUOUS_CLASS:
... | def get_all_params(cls):
"""
Compiles and returns all parameters for all :py:class:`Task`.
:return: a generator of tuples (TODO: we should make this more elegant)
"""
for task_name, task_cls in six.iteritems(cls._get_reg()):
if task_cls == cls.AMBIGUOUS_CLASS:
... | [
"Compiles",
"and",
"returns",
"all",
"parameters",
"for",
"all",
":",
"py",
":",
"class",
":",
"Task",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task_register.py#L186-L196 | [
"def",
"get_all_params",
"(",
"cls",
")",
":",
"for",
"task_name",
",",
"task_cls",
"in",
"six",
".",
"iteritems",
"(",
"cls",
".",
"_get_reg",
"(",
")",
")",
":",
"if",
"task_cls",
"==",
"cls",
".",
"AMBIGUOUS_CLASS",
":",
"continue",
"for",
"param_name... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Register._editdistance | Simple unweighted Levenshtein distance | luigi/task_register.py | def _editdistance(a, b):
""" Simple unweighted Levenshtein distance """
r0 = range(0, len(b) + 1)
r1 = [0] * (len(b) + 1)
for i in range(0, len(a)):
r1[0] = i + 1
for j in range(0, len(b)):
c = 0 if a[i] is b[j] else 1
r1[j + 1] =... | def _editdistance(a, b):
""" Simple unweighted Levenshtein distance """
r0 = range(0, len(b) + 1)
r1 = [0] * (len(b) + 1)
for i in range(0, len(a)):
r1[0] = i + 1
for j in range(0, len(b)):
c = 0 if a[i] is b[j] else 1
r1[j + 1] =... | [
"Simple",
"unweighted",
"Levenshtein",
"distance"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task_register.py#L199-L213 | [
"def",
"_editdistance",
"(",
"a",
",",
"b",
")",
":",
"r0",
"=",
"range",
"(",
"0",
",",
"len",
"(",
"b",
")",
"+",
"1",
")",
"r1",
"=",
"[",
"0",
"]",
"*",
"(",
"len",
"(",
"b",
")",
"+",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"0",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | Register._module_parents | >>> list(Register._module_parents('a.b'))
['a.b', 'a', ''] | luigi/task_register.py | def _module_parents(module_name):
'''
>>> list(Register._module_parents('a.b'))
['a.b', 'a', '']
'''
spl = module_name.split('.')
for i in range(len(spl), 0, -1):
yield '.'.join(spl[0:i])
if module_name:
yield '' | def _module_parents(module_name):
'''
>>> list(Register._module_parents('a.b'))
['a.b', 'a', '']
'''
spl = module_name.split('.')
for i in range(len(spl), 0, -1):
yield '.'.join(spl[0:i])
if module_name:
yield '' | [
">>>",
"list",
"(",
"Register",
".",
"_module_parents",
"(",
"a",
".",
"b",
"))",
"[",
"a",
".",
"b",
"a",
"]"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/task_register.py#L234-L243 | [
"def",
"_module_parents",
"(",
"module_name",
")",
":",
"spl",
"=",
"module_name",
".",
"split",
"(",
"'.'",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"spl",
")",
",",
"0",
",",
"-",
"1",
")",
":",
"yield",
"'.'",
".",
"join",
"(",
"spl",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _get_task_statuses | Retrieve task statuses from ECS API
Returns list of {RUNNING|PENDING|STOPPED} for each id in task_ids | luigi/contrib/ecs.py | def _get_task_statuses(task_ids, cluster):
"""
Retrieve task statuses from ECS API
Returns list of {RUNNING|PENDING|STOPPED} for each id in task_ids
"""
response = client.describe_tasks(tasks=task_ids, cluster=cluster)
# Error checking
if response['failures'] != []:
raise Exception... | def _get_task_statuses(task_ids, cluster):
"""
Retrieve task statuses from ECS API
Returns list of {RUNNING|PENDING|STOPPED} for each id in task_ids
"""
response = client.describe_tasks(tasks=task_ids, cluster=cluster)
# Error checking
if response['failures'] != []:
raise Exception... | [
"Retrieve",
"task",
"statuses",
"from",
"ECS",
"API"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/ecs.py#L68-L85 | [
"def",
"_get_task_statuses",
"(",
"task_ids",
",",
"cluster",
")",
":",
"response",
"=",
"client",
".",
"describe_tasks",
"(",
"tasks",
"=",
"task_ids",
",",
"cluster",
"=",
"cluster",
")",
"# Error checking",
"if",
"response",
"[",
"'failures'",
"]",
"!=",
... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | _track_tasks | Poll task status until STOPPED | luigi/contrib/ecs.py | def _track_tasks(task_ids, cluster):
"""Poll task status until STOPPED"""
while True:
statuses = _get_task_statuses(task_ids, cluster)
if all([status == 'STOPPED' for status in statuses]):
logger.info('ECS tasks {0} STOPPED'.format(','.join(task_ids)))
break
time.... | def _track_tasks(task_ids, cluster):
"""Poll task status until STOPPED"""
while True:
statuses = _get_task_statuses(task_ids, cluster)
if all([status == 'STOPPED' for status in statuses]):
logger.info('ECS tasks {0} STOPPED'.format(','.join(task_ids)))
break
time.... | [
"Poll",
"task",
"status",
"until",
"STOPPED"
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/ecs.py#L88-L96 | [
"def",
"_track_tasks",
"(",
"task_ids",
",",
"cluster",
")",
":",
"while",
"True",
":",
"statuses",
"=",
"_get_task_statuses",
"(",
"task_ids",
",",
"cluster",
")",
"if",
"all",
"(",
"[",
"status",
"==",
"'STOPPED'",
"for",
"status",
"in",
"statuses",
"]",... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToTable.create_table | 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 transaction. | luigi/contrib/rdbms.py | 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 table a... | 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 table a... | [
"Override",
"to",
"provide",
"code",
"for",
"creating",
"the",
"target",
"table",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/rdbms.py#L201-L219 | [
"def",
"create_table",
"(",
"self",
",",
"connection",
")",
":",
"if",
"len",
"(",
"self",
".",
"columns",
"[",
"0",
"]",
")",
"==",
"1",
":",
"# only names of columns specified, no types",
"raise",
"NotImplementedError",
"(",
"\"create_table() not implemented for %... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
train | CopyToTable.init_copy | Override to perform custom queries.
Any code here will be formed in the same transaction as the main copy, just prior to copying data.
Example use cases include truncating the table or removing all data older than X in the database
to keep a rolling window of data available in the table. | luigi/contrib/rdbms.py | def init_copy(self, connection):
"""
Override to perform custom queries.
Any code here will be formed in the same transaction as the main copy, just prior to copying data.
Example use cases include truncating the table or removing all data older than X in the database
to keep a ... | def init_copy(self, connection):
"""
Override to perform custom queries.
Any code here will be formed in the same transaction as the main copy, just prior to copying data.
Example use cases include truncating the table or removing all data older than X in the database
to keep a ... | [
"Override",
"to",
"perform",
"custom",
"queries",
"."
] | spotify/luigi | python | https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/rdbms.py#L232-L247 | [
"def",
"init_copy",
"(",
"self",
",",
"connection",
")",
":",
"# TODO: remove this after sufficient time so most people using the",
"# clear_table attribtue will have noticed it doesn't work anymore",
"if",
"hasattr",
"(",
"self",
",",
"\"clear_table\"",
")",
":",
"raise",
"Exc... | c5eca1c3c3ee2a7eb612486192a0da146710a1e9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.