Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenerTarget Support. #1555

Merged
merged 1 commit into from
Feb 22, 2016

Conversation

KyleJamesWalker
Copy link
Contributor

Allow a single luigi target to open multiple file system types. This can allow for easier local testing, unit test, and greater flexibility of your luigi tasks.

Example:

import luigi

from luigi.contrib.opener import OpenerTarget

class ConfigurableTask(luigi.Task):
    output_file = luigi.parameter(default='s3://foo/bar/baz.txt')

    def run(self):
        payload = {'foo': 'bar'}
        with self.output().open('w') as fp:
            json.dump(payload, fp)

    def output(self):
        return OpenerTarget(self.output_file)

example1 = ConfigurableTask(output_file='/tmp/local_file.txt')
example2 = ConfigurableTask(output_file='mock://tmp/memory_file.txt')

{% endhighlight %}

I've only add three target types so far to make sure this pattern is accepted into the code base (and this is all I needed to run our pipeline in all environments needed).

Allow a single luigi target to open multiple file system types.  This
can allow for easier local testing, unit test, and greater flexability
of your luigi tasks.
@KyleJamesWalker
Copy link
Contributor Author

Not sure what's going on with the error, seems to be the same error in #1547, #1543, #1538, and others.

Warning, treated as error:
./luigi/doc/api/luigi.rst:11: WARNING: Could not lex literal_block as "python3". Highlighting skipped.

@KyleJamesWalker
Copy link
Contributor Author

Note this is fixed if you edit ./luigi/.tox/docs/lib/python2.7/site-packages/sphinx/config.py and change highlight_language = ('python3', 'env'), to highlight_language = ('python', 'env'),

Maybe a config was changed, or the sphinx version isn't pinned and it had a breaking change added?

memory.

example:
* mock://foo/bar.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor thing but shouldn't it be just "mock:foo/bar.txt"? double slash usually indicates a hostname

not blocking

@KyleJamesWalker
Copy link
Contributor Author

I set it up to use a URI-like syntax (inspired by the syntax of http://commons.apache.org/vfs/filesystems.html).

@erikbern
Copy link
Contributor

that's great – thanks for making sure we adhere to standards!

erikbern added a commit that referenced this pull request Feb 22, 2016
@erikbern erikbern merged commit 2feb138 into spotify:master Feb 22, 2016
@Tarrasch
Copy link
Contributor

Tarrasch commented Nov 17, 2016

@sisidra didn't Spotify want something like this once?

@KyleJamesWalker, out of curiosity, are you still using this module. Is everything working out good?

@sisidra
Copy link
Contributor

sisidra commented Nov 17, 2016

@Tarrasch not sure. We are in JVM land and Luigi is only orchestration layer. Anyway thanks for pinging ;)

@Tarrasch
Copy link
Contributor

I think luigi only for orchestration is the case for many luigi players these days. I also don't use luigi MR today based on my experience from Spotify. Anyway I thought Spotify previously had migration issues when it came to HDFS --> GFS migration. And that this Opener factory could smooth things. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants