本文整理汇总了Python中luigi.Target方法的典型用法代码示例。如果您正苦于以下问题:Python luigi.Target方法的具体用法?Python luigi.Target怎么用?Python luigi.Target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类luigi
的用法示例。
在下文中一共展示了luigi.Target方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_input_args
# 需要导入模块: import luigi [as 别名]
# 或者: from luigi import Target [as 别名]
def _get_input_args(self):
# TODO(brianm): this doesn't work when subclass yields from `requires`
job_input = self.input()
if isinstance(job_input, luigi.Target):
job_input = {"input": job_input}
if len(job_input) == 0: # default requires()
return []
if not isinstance(job_input, dict):
raise ValueError("Input (requires()) must be dict type")
input_args = []
for (name, targets) in job_input.items():
uris = [get_uri(target) for target in luigi.task.flatten(targets)]
if isinstance(targets, dict):
# If targets is a dict that means it had multiple outputs. In this case make the
# input args "<input key>-<task output key>"
names = ["%s-%s" % (name, key) for key in targets.keys()]
else:
names = [name] * len(uris)
for (arg_name, uri) in zip(names, uris):
input_args.append("--%s=%s" % (arg_name, uri))
return input_args
示例2: test_methods
# 需要导入模块: import luigi [as 别名]
# 或者: from luigi import Target [as 别名]
def test_methods(self):
wf = sl.WorkflowTask()
touta = wf.new_task('tout', MultiOutTask,
an_id='a')
toutb = wf.new_task('tout', MultiOutTask,
an_id='b')
toutc = wf.new_task('tout', MultiOutTask,
an_id='c')
tin = wf.new_task('tout', MultiInTask)
tin.in_multi = [touta.out_multi, {'a': toutb.out_multi, 'b': toutc.out_multi()}]
# Assert outputs returns luigi targets, or list of luigi targets
outs = touta.output()
self.assertIsInstance(outs, list)
for out in outs:
self.assertIsInstance(out, luigi.Target)
reqs = tin.requires()
self.assertIsInstance(reqs, list)
for req in reqs:
self.assertIsInstance(req, luigi.Task)
示例3: __init__
# 需要导入模块: import luigi [as 别名]
# 或者: from luigi import Target [as 别名]
def __init__(self, *args, **kwargs):
super(PythonDataflowTask, self).__init__(*args, **kwargs)
self._output = self.output()
if isinstance(self._output, luigi.Target):
self._output = {"output": self._output}
if self.job_name is None:
# job_name must consist of only the characters [-a-z0-9]
cls_name = self.__class__.__name__.replace("_", "-").lower()
self.job_name = "{cls_name}-{timestamp}".format(cls_name=cls_name,
timestamp=str(int(time.time())))
示例4: _get_input_args
# 需要导入模块: import luigi [as 别名]
# 或者: from luigi import Target [as 别名]
def _get_input_args(self):
"""
Collects outputs from requires() and converts them to input arguments.
file_pattern() is called to construct input file path glob with default value "part-*"
"""
job_input = self.input()
if isinstance(job_input, luigi.Target):
job_input = {"input": job_input}
if not isinstance(job_input, dict):
raise ValueError("Input (requires()) must be dict type")
input_args = []
file_pattern_dict = self._get_file_pattern()
for (name, targets) in job_input.items():
uri_targets = luigi.task.flatten(targets)
pattern = file_pattern_dict.get(name, "part-*")
uris = [self._get_input_uri(pattern, uri_target) for uri_target in uri_targets]
if isinstance(targets, dict):
# If targets is a dict that means it had multiple outputs.
# Make the input args in that case "<input key>-<task output key>"
names = ["%s-%s" % (name, key) for key in targets.keys()]
else:
names = [name] * len(uris)
for (arg_name, uri) in zip(names, uris):
input_args.append("--%s=%s" % (arg_name, uri))
return input_args
示例5: output
# 需要导入模块: import luigi [as 别名]
# 或者: from luigi import Target [as 别名]
def output(self):
# `make_target` makes an instance of `luigi.Target`.
# This infers the output format and the destination of an output objects.
# The target file path is
# '{TaskOnKart.workspace_directory}/output_of_task_b_{self.make_unique_id()}.pkl'.
return self.make_target('output_of_task_b.pkl')
示例6: get_object_storage_target
# 需要导入模块: import luigi [as 别名]
# 或者: from luigi import Target [as 别名]
def get_object_storage_target(path: str, format: Format) -> luigi.Target:
if path.startswith('s3://'):
return luigi.contrib.s3.S3Target(path, client=S3Config().get_s3_client(), format=format)
elif path.startswith('gs://'):
return luigi.contrib.gcs.GCSTarget(path, client=GCSConfig().get_gcs_client(), format=format)
else:
raise