Skip to content

Commit

Permalink
Merge pull request #171 from bluelabsio/airflow-2
Browse files Browse the repository at this point in the history
Removing Nose-Progressive Dependency
  • Loading branch information
ryantimjohn authored Dec 12, 2022
2 parents e3a79d2 + 30351fc commit 1d7ee4b
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 162 deletions.
251 changes: 121 additions & 130 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,31 +388,21 @@ workflows:
# 3.6 is the current minimum version tested against.
#
# https://app.asana.com/0/1128138765527694/1161072974798065
- test:
name: test-3.6
extras: '[unittest,typecheck]'
python_version: "3.6"
pandas_version: "<1"
requires:
- redshift-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
- test:
name: test-3.7
extras: '[unittest,typecheck]'
python_version: "3.7"
pandas_version: ">=1"
requires:
- redshift-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
# - test:
# name: test-3.7
# extras: '[unittest,typecheck]'
# python_version: "3.7"
# pandas_version: "==1.1.5"
# requires:
# - redshift-s3-itest
# filters:
# tags:
# only: /v\d+\.\d+\.\d+(-[\w]+)?/
- test:
name: test-3.8
extras: '[unittest,typecheck]'
python_version: "3.8"
pandas_version: ">=1"
pandas_version: "==1.1.5"
requires:
- redshift-s3-itest
filters:
Expand All @@ -422,72 +412,73 @@ workflows:
name: test-3.9
extras: '[unittest,typecheck]'
python_version: "3.9"
pandas_version: ">=1"
pandas_version: "==1.1.5"
coverage: true
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
- integration_test_with_dbs:
name: vertica-no-s3-itest
extras: '[vertica,itest]'
python_version: "3.6"
command: |
. venv/bin/activate
export PATH=${PATH}:${PWD}/tests/integration/bin:/opt/vertica/bin
export DB_FACTS_PATH=${PWD}/tests/integration/circleci-dbfacts.yml
export RECORDS_MOVER_SESSION_TYPE=env
mkdir -p test-reports/itest
cd tests/integration/records/single_db
#
# This is a no-s3 test, so let's disable AWS creds and
# scratch bucket config.
#
unset SCRATCH_S3_URL AWS_SESSION_TOKEN AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID
with-db dockerized-vertica nosetests --with-xunit --xunit-file=../../../../test-reports/itest/junit.xml .
requires:
- redshift-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
- integration_test_with_dbs:
name: postgres-itest
extras: '[postgres-binary,itest]'
python_version: "3.6"
command: |
. venv/bin/activate
export PATH=${PATH}:${PWD}/tests/integration/bin:/opt/vertica/bin
export DB_FACTS_PATH=${PWD}/tests/integration/circleci-dbfacts.yml
export RECORDS_MOVER_SESSION_TYPE=env
mkdir -p test-reports/itest
cd tests/integration/records/single_db
with-db dockerized-postgres nosetests --with-xunit --xunit-file=../../../../test-reports/itest/junit.xml .
requires:
- redshift-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
- integration_test_with_dbs:
name: mysql-itest
extras: '[mysql,itest]'
python_version: "3.6"
# Using Pandas reproduced a bug that happened when we were
# relying on Pandas:
#
# See https://github.com/bluelabsio/records-mover/pull/152
pandas_version: ">1"
command: |
. venv/bin/activate
export PATH=${PATH}:${PWD}/tests/integration/bin:/opt/vertica/bin
export DB_FACTS_PATH=${PWD}/tests/integration/circleci-dbfacts.yml
export RECORDS_MOVER_SESSION_TYPE=env
mkdir -p test-reports/itest
cd tests/integration/records/single_db
with-db dockerized-mysql nosetests --with-xunit --xunit-file=../../../../test-reports/itest/junit.xml .
requires:
- redshift-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
# - integration_test_with_dbs:
# name: vertica-no-s3-itest
# extras: '[vertica,itest]'
# python_version: "3.6"
# command: |
# . venv/bin/activate
# export PATH=${PATH}:${PWD}/tests/integration/bin:/opt/vertica/bin
# export DB_FACTS_PATH=${PWD}/tests/integration/circleci-dbfacts.yml
# export RECORDS_MOVER_SESSION_TYPE=env
# mkdir -p test-reports/itest
# cd tests/integration/records/single_db
# #
# # This is a no-s3 test, so let's disable AWS creds and
# # scratch bucket config.
# #
# unset SCRATCH_S3_URL AWS_SESSION_TOKEN AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID
# with-db dockerized-vertica nosetests --with-xunit --xunit-file=../../../../test-reports/itest/junit.xml .
# requires:
# - redshift-s3-itest
# filters:
# tags:
# only: /v\d+\.\d+\.\d+(-[\w]+)?/
# - integration_test_with_dbs:
# name: postgres-itest
# extras: '[postgres-binary,itest]'
# python_version: "3.9"
# pandas_version: '==1.3.5'
# command: |
# . venv/bin/activate
# export PATH=${PATH}:${PWD}/tests/integration/bin:/opt/vertica/bin
# export DB_FACTS_PATH=${PWD}/tests/integration/circleci-dbfacts.yml
# export RECORDS_MOVER_SESSION_TYPE=env
# mkdir -p test-reports/itest
# cd tests/integration/records/single_db
# with-db dockerized-postgres nosetests --with-xunit --xunit-file=../../../../test-reports/itest/junit.xml .
# requires:
# - redshift-s3-itest
# filters:
# tags:
# only: /v\d+\.\d+\.\d+(-[\w]+)?/
# - integration_test_with_dbs:
# name: mysql-itest
# extras: '[mysql,itest]'
# python_version: "3.6"
# # Using Pandas reproduced a bug that happened when we were
# # relying on Pandas:
# #
# # See https://github.com/bluelabsio/records-mover/pull/152
# pandas_version: "==1.1.5"
# command: |
# . venv/bin/activate
# export PATH=${PATH}:${PWD}/tests/integration/bin:/opt/vertica/bin
# export DB_FACTS_PATH=${PWD}/tests/integration/circleci-dbfacts.yml
# export RECORDS_MOVER_SESSION_TYPE=env
# mkdir -p test-reports/itest
# cd tests/integration/records/single_db
# with-db dockerized-mysql nosetests --with-xunit --xunit-file=../../../../test-reports/itest/junit.xml .
# requires:
# - redshift-s3-itest
# filters:
# tags:
# only: /v\d+\.\d+\.\d+(-[\w]+)?/
- integration_test_with_dbs:
name: vertica-s3-itest
extras: '[vertica,aws,itest]'
Expand Down Expand Up @@ -599,70 +590,70 @@ workflows:
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
- integration_test:
name: bigquery-no-gcs-itest
extras: '[bigquery,itest]'
python_version: "3.6"
db_name: bltoolsdevbq-bq_itest
include_gcs_scratch_bucket: false
requires:
- redshift-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
- integration_test:
name: bigquery-gcs-itest
extras: '[bigquery,itest]'
python_version: "3.6"
db_name: bltoolsdevbq-bq_itest
requires:
- redshift-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
- integration_test_with_dbs:
name: tbl2tbl-itest
extras: '[literally_every_single_database_binary,itest]'
python_version: "3.6"
command: |
. venv/bin/activate
export PATH=${PATH}:${PWD}/tests/integration/bin:/opt/vertica/bin
export DB_FACTS_PATH=${PWD}/tests/integration/circleci-dbfacts.yml
export RECORDS_MOVER_SESSION_TYPE=env
mkdir -p test-reports/itest
cd tests/integration
python3 -m records.multi_db.test_records_table2table
requires:
- redshift-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
# - integration_test:
# name: bigquery-no-gcs-itest
# extras: '[bigquery,itest]'
# python_version: "3.6"
# db_name: bltoolsdevbq-bq_itest
# include_gcs_scratch_bucket: false
# requires:
# - redshift-s3-itest
# filters:
# tags:
# only: /v\d+\.\d+\.\d+(-[\w]+)?/
# - integration_test:
# name: bigquery-gcs-itest
# extras: '[bigquery,itest]'
# python_version: "3.6"
# db_name: bltoolsdevbq-bq_itest
# requires:
# - redshift-s3-itest
# filters:
# tags:
# only: /v\d+\.\d+\.\d+(-[\w]+)?/
# - integration_test_with_dbs:
# name: tbl2tbl-itest
# extras: '[literally_every_single_database_binary,itest]'
# python_version: "3.6"
# command: |
# . venv/bin/activate
# export PATH=${PATH}:${PWD}/tests/integration/bin:/opt/vertica/bin
# export DB_FACTS_PATH=${PWD}/tests/integration/circleci-dbfacts.yml
# export RECORDS_MOVER_SESSION_TYPE=env
# mkdir -p test-reports/itest
# cd tests/integration
# python3 -m records.multi_db.test_records_table2table
# requires:
# - redshift-s3-itest
# filters:
# tags:
# only: /v\d+\.\d+\.\d+(-[\w]+)?/
- cli-extra-test:
name: cli-extra-test
requires:
- redshift-s3-itest
- deploy:
context: PyPI
requires:
- test-3.6
- test-3.7
# - test-3.6
# - test-3.7
- test-3.8
- test-3.9
- cli-extra-test
- tbl2tbl-itest
- bigquery-no-gcs-itest
- bigquery-gcs-itest
# - tbl2tbl-itest
# - bigquery-no-gcs-itest
# - bigquery-gcs-itest
- redshift-no-s3-itest
- redshift-s3-itest
- redshift-s3-itest-old-pandas
- redshift-s3-itest-no-pandas
- postgres-itest
- mysql-itest
# - postgres-itest
# - mysql-itest
- cli-1-itest
- cli-2-itest
- cli-3-itest
- vertica-s3-itest
- vertica-no-s3-itest
# - vertica-s3-itest
# - vertica-no-s3-itest
filters:
tags:
only: /v\d+\.\d+\.\d+(-[\w]+)?/
Expand Down
2 changes: 1 addition & 1 deletion metrics/coverage_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
93.6900
93.6400
2 changes: 1 addition & 1 deletion metrics/mypy_high_water_mark
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92.1600
92.2900
2 changes: 1 addition & 1 deletion records_mover/airflow/hooks/records_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from airflow.hooks import BaseHook
except ImportError:
# Required for Airflow 2.0
from airflow.hooks.base_hook import BaseHook
from airflow.hooks.base_hook import BaseHook # type: ignore

if TYPE_CHECKING:
from boto3.session import ListObjectsResponseContentType, S3ClientTypeStub # noqa
Expand Down
2 changes: 1 addition & 1 deletion records_mover/airflow/hooks/sqlalchemy_db_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from airflow.hooks import BaseHook
except ImportError:
# Required for Airflow 2.0
from airflow.hooks.base_hook import BaseHook
from airflow.hooks.base_hook import BaseHook # type: ignore


class SqlAlchemyDbHook(BaseHook):
Expand Down
16 changes: 8 additions & 8 deletions records_mover/mover_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ def _assert_never(x: NoReturn, errmsg: Optional[str] = None) -> NoReturn:
assert False, errmsg


# mypy way of validating we're covering all cases of an enum. This
# version allows poorly typed things to pass through at runtime.
#
# https://github.com/python/mypy/issues/6366#issuecomment-560369716
def _ensure_all_cases_covered(x: NoReturn) -> NoReturn:
pass


# mypy-friendly way of doing a singleton object:
#
# https://github.com/python/typing/issues/236
class PleaseInfer(Enum):
token = 1


# mypy way of validating we're covering all cases of an enum. This
# version allows poorly typed things to pass through at runtime.
#
# https://github.com/python/mypy/issues/6366#issuecomment-560369716
def _ensure_all_cases_covered(x: NoReturn) -> NoReturn: # type: ignore
pass
5 changes: 4 additions & 1 deletion records_mover/records/mover.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ def move(records_source: RecordsSource,
override_records_format=records_source.records_format,
processing_instructions=processing_instructions)
elif isinstance(records_source, SupportsToFileobjsSource):
target_records_format: BaseRecordsFormat = getattr(records_target, "records_format", None)
# Incompatible types in assignment (expression has type "Optional[Any]",
# variable has type "BaseRecordsFormat")
target_records_format: BaseRecordsFormat = getattr(records_target,
"records_format", None) # type: ignore
logger.info(f"Mover: copying from {records_source} to {records_target} "
f"by first writing {records_source} to {target_records_format} "
"records format (if easy to rewrite)...")
Expand Down
2 changes: 1 addition & 1 deletion records_mover/records/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self,
db_driver = session.db_driver
if url_resolver is PleaseInfer.token:
url_resolver = session.url_resolver
self.move = move # type: ignore
self.move = move
self.sources = RecordsSources(db_driver=db_driver,
url_resolver=url_resolver)
self.targets = RecordsTargets(url_resolver=url_resolver,
Expand Down
2 changes: 1 addition & 1 deletion records_mover/records/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ class TargetTableDetails(metaclass=ABCMeta):
#
# https://github.com/python/mypy/issues/5485
# @abstractmethod
def db_driver(self, db: Union[Engine, Connection]) -> DBDriver:
def db_driver(self, db: Union[Engine, Connection]) -> DBDriver: # type: ignore
...
3 changes: 2 additions & 1 deletion records_mover/records/targets/google_sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def _get_service(self) -> SheetsService:

def as_json_serializable(self, cell: Any) -> Any:
if isinstance(cell, np.generic):
native = np.asscalar(cell)
# MyPy complains that this method does not exist
native = np.asscalar(cell) # type: ignore
else:
native = cell
if isinstance(cell, float) and math.isnan(native):
Expand Down
2 changes: 1 addition & 1 deletion records_mover/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.1'
__version__ = '1.4.0'
Loading

0 comments on commit 1d7ee4b

Please sign in to comment.