luigi.contrib.external_daily_snapshot
Classes
|
Abstract class containing a helper method to fetch the latest snapshot. |
- class luigi.contrib.external_daily_snapshot.ExternalDailySnapshot(*args, **kwargs)[source]
Abstract class containing a helper method to fetch the latest snapshot.
Example:
class MyTask(luigi.Task): def requires(self): return PlaylistContent.latest()
All tasks subclassing
ExternalDailySnapshotmust have aluigi.DateParameternameddate.You can also provide additional parameters to the class and also configure lookback size.
Example:
ServiceLogs.latest(service="radio", lookback=21)
- date
Parameter whose value is a
date.A DateParameter is a Date string formatted
YYYY-MM-DD. For example,2013-07-10specifies July 10, 2013.DateParameters are 90% of the time used to be interpolated into file system paths or the like. Here is a gentle reminder of how to interpolate date parameters into strings:
class MyTask(luigi.Task): date = luigi.DateParameter() def run(self): templated_path = "/my/path/to/my/dataset/{date:%Y/%m/%d}/" instantiated_path = templated_path.format(date=self.date) # print(instantiated_path) --> /my/path/to/my/dataset/2016/06/09/ # ... use instantiated_path ...
To set this parameter to default to the current day. You can write code like this:
import datetime class MyTask(luigi.Task): date = luigi.DateParameter(default=datetime.date.today())