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

Fix deprecation warnings (breaking) #44

Merged
merged 11 commits into from
Apr 19, 2020
Merged

Fix deprecation warnings (breaking) #44

merged 11 commits into from
Apr 19, 2020

Conversation

vinceatbluelabs
Copy link
Contributor

@vinceatbluelabs vinceatbluelabs commented Apr 19, 2020

I've been keeping a list of the deprecation errors we receive as part of Records Mover usage / builds. This takes care of a bunch of them!

This also revealed along the way that I forgot to remove some deprecated factor method arguments.

There are still some Airflow deprecation warnings that are false alarms - there's an unresolved issue here: https://issues.apache.org/jira/browse/AIRFLOW-5138

@vinceatbluelabs vinceatbluelabs marked this pull request as ready for review April 19, 2020 19:17
job = client.load_table_from_file(fileobj,
table_ref,
f"{schema}.{table}",
Copy link
Contributor Author

@vinceatbluelabs vinceatbluelabs Apr 19, 2020

Choose a reason for hiding this comment

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

/Users/broz/src/bluelabs-joblib-python/bluelabs_joblib/db/bigquery/loader.py:50: PendingDeprecationWarning: Client.dataset is deprecated and will be removed in a future version. Use a string like 'my_project.my_dataset' or a cloud.google.bigquery.DatasetReference object, instead.

@@ -68,7 +68,7 @@ def load(self,
session_token=aws_creds.token, manifest=True,
region=directory.loc.region, # type: ignore
empty_as_null=True,
**redshift_options)
**redshift_options) # type: ignore
Copy link
Contributor Author

@vinceatbluelabs vinceatbluelabs Apr 19, 2020

Choose a reason for hiding this comment

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

I created some initial typestubs for sqlalchemy_redshift to improve our coverage here; it's not yet smart enough to understand the kwargs in detail, though.

redshift_options['compression'] = Compression.bzip2
else:
cant_handle_hint(fail_if_cant_handle_hint, 'compression', hints)
redshift_options['compression'] = hints['compression']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sqlalchemy_redshift is now requiring that we use enums they provide. This is probably a good idea, given it looks like we were passing in the wrong strings for their BZIP2 and LZOP compression!

/Users/broz/.pyenv/versions/3.8.1/envs/bluelabs-joblib-python-3.8.1/lib/python3.8/site-packages/sqlalchemy_redshift/commands.py:429: DeprecationWarning: 'GZIP' should be, <Compression.gzip: 'GZIP'>, an instance of <enum 'Compression'>
warnings.warn(msg, DeprecationWarning)
/Users/broz/.pyenv/versions/3.8.1/envs/bluelabs-joblib-python-3.8.1/lib/python3.8/site-packages/sqlalchemy_redshift/commands.py:429: DeprecationWarning: 'UTF8' should be, <Encoding.utf8: 'UTF8'>, an instance of <enum 'Encoding'>

:param processing_instructions: Instructions used during creation of the schema SQL.
:param records_schema: Description of the column names and types of the records.
:param include_index: If true, the Pandas dataframe index column will be included in
the move.
"""

warn_deprecated(schema_name=schema_name, table_name=table_name, db_engine=db_engine)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed this in the big breaking release before! This makes this a breaking PR. The next release will also include the extras breaking change, so I figured we might as well. I'll note this in the release notes and bump the middle release per semver, since we're still pre-1.0. I'll also collect the internal uses in the corresponding internal ticket and we can figure out how to handle those.

@vinceatbluelabs vinceatbluelabs changed the title Fix deprecation warnings Fix deprecation warnings (breaking) Apr 19, 2020
Copy link
Contributor

@cwegrzyn cwegrzyn left a comment

Choose a reason for hiding this comment

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

One or two small things noted below, but nothing major! :shipit:

redshift_options['compression'] = Compression.bzip2
else:
cant_handle_hint(fail_if_cant_handle_hint, 'compression', hints)
redshift_options['compression'] = hints['compression']
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed below for encoding you have a fallback to a fixed value in the else clause, but here you pass the value through directly. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. Come to think of it, consulting the Enum seems like a reasonable approach that would allow an old records mover to work with a new sqlalchemy-redshift, so I'll give that a shot.

@cwegrzyn
Copy link
Contributor

It's one thing.

@vinceatbluelabs vinceatbluelabs merged commit 9aecda7 into master Apr 19, 2020
@vinceatbluelabs vinceatbluelabs deleted the undeprecate branch April 19, 2020 23:36
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