8000 Added port property to CopyToTable by adilkhash · Pull Request #2561 · spotify/luigi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added port property to CopyToTable #2561

New issue 8000

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

Merged
merged 4 commits into from
Nov 20, 2018

Conversation

adilkhash
Copy link
Contributor

Description

Added abstract property port to CopyToTable

Motivation and Context

Sometimes it is not comfortable to provide port inside host property, i.e. localhost:port, hence added optional port property to CopyToTable task in case when database listens custom port. Currently the only way to supply port is via host.

Have you tested this? If so, how?

"I ran my jobs with this code and it works for me."

Copy link
Collaborator
@dlstadther dlstadther left a comment

Choose a reason for hiding this comment

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

As written, this is a breaking change for anyone using a subclassed version of RDBMS CopytoTable (postgres and redshift) and doesn't explicitly provide port as its own property.

Could you explain how providing host:port is uncomfortable? I'm not sold on this addition as written.

I'd be more open to a solution which optionally accepts port property. I imagine there is an example of something similar in postgres.py or redshift.py.

Happy to discuss further! Thanks for wishing to contribute back to Luigi ! :)

@adilkhash
Copy link
Contributor Author
adilkhash commented Oct 29, 2018

Agree, did not pay attention to that, sorry. Fixed to optional property.
Speaking about host:port option. I use .env files to store credentials, i.e:

DB_HOST = 'localhost'
DB_NAME = 'database'
DB_USER = 'user'
DB_PASSWORD = 'password'
DB_PORT = 15432

DB_HOST variable is actively used everywhere and in order not to break things out, inside CopyToTable task I have something like this:

class MyCopyToTable(CopyToTable):
    host = f'{config.DB_HOST}:{config.DB_PORT}'

Which looks a little bit ugly :)

P.S. I was curious why PostgresTarget accepts optional port but CopyToTable does not.

Copy link
Collaborator
@dlstadther dlstadther left a comment

Choose a reason for hiding this comment

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

This is functionally kosher now.

As to why PostgresTarget and CopyToTable differ as such, I don't have a strong reason. PostgresTarget predates me. But as most luigi classes, they were added for a specific use case at a point in time. If it is your preference to refactor, i'll review.

Otherwise, i'll merge this in the next couple days

@adilkhash
Copy link
Contributor Author

Is it possible to merge this one?

@dlstadther dlstadther merged commit fbc5bda into spotify:master Nov 20, 2018
@dlstadther
Copy link
Collaborator

Thanks for pinging @adilkhash . Merged!

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.

2 participants
0