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

Get the file location based on path and conn_id #1478

Merged
merged 63 commits into from
Dec 28, 2022
Merged

Get the file location based on path and conn_id #1478

merged 63 commits into from
Dec 28, 2022

Conversation

sunank200
Copy link
Contributor

@sunank200 sunank200 commented Dec 21, 2022

Description

What is the current behavior?

Currently create_file_location is picking module path based on filetype.value even tough the conn_id is passed. https://github.com/astronomer/astro-sdk/blob/main/python-sdk/src/astro/files/locations/__init__.py#L23 get_location_type doesn't take care of fetching the filelocation based on conn_type as per conn_id at all. It just picks up from the path.

closes: #1471

What is the new behavior?

  • Add validate_conn() in BaseFilelocation class to match file path and connection type

Does this introduce a breaking change?

No

Checklist

  • Created tests which fail without the change (if possible)
  • Extended the README / documentation, if necessary

Copy link
Contributor

@pankajastro pankajastro left a comment

Choose a reason for hiding this comment

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

do we need a test for this change?

@utkarsharma2
Copy link
Collaborator

Also, I think, we can add this quirk to docs as well.

@codecov
Copy link

codecov bot commented Dec 21, 2022

Codecov Report

Base: 93.65% // Head: 93.67% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (04df347) compared to base (aa8167f).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1478      +/-   ##
==========================================
+ Coverage   93.65%   93.67%   +0.02%     
==========================================
  Files          84       84              
  Lines        4067     4082      +15     
  Branches      402      404       +2     
==========================================
+ Hits         3809     3824      +15     
  Misses        177      177              
  Partials       81       81              
Impacted Files Coverage Δ
python-sdk/src/astro/files/locations/__init__.py 100.00% <100.00%> (ø)
python-sdk/src/astro/files/locations/amazon/s3.py 91.66% <100.00%> (+0.17%) ⬆️
python-sdk/src/astro/files/locations/azure/wasb.py 97.36% <100.00%> (+0.07%) ⬆️
python-sdk/src/astro/files/locations/base.py 76.28% <100.00%> (+2.42%) ⬆️
python-sdk/src/astro/files/locations/google/gcs.py 91.37% <100.00%> (+0.15%) ⬆️
...hon-sdk/src/astro/files/locations/google/gdrive.py 97.64% <100.00%> (+0.02%) ⬆️
python-sdk/src/astro/files/locations/http.py 100.00% <100.00%> (ø)
python-sdk/src/astro/files/locations/local.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

python-sdk/src/astro/files/locations/http.py Outdated Show resolved Hide resolved
python-sdk/src/astro/files/locations/http.py Outdated Show resolved Hide resolved
python-sdk/tests/files/locations/test_location_base.py Outdated Show resolved Hide resolved
python-sdk/tests/files/operators/test_files.py Outdated Show resolved Hide resolved
python-sdk/tests/files/operators/test_files.py Outdated Show resolved Hide resolved
python-sdk/tests/files/operators/test_files.py Outdated Show resolved Hide resolved
@sunank200 sunank200 requested a review from kaxil December 28, 2022 16:02
@kaxil
Copy link
Collaborator

kaxil commented Dec 28, 2022

test is failing:

FAILED tests/files/operators/test_files.py::test_get_file_list_execute_gcs - airflow.exceptions.AirflowNotFoundException: The conn_id `bigquery` isn't defined

@sunank200 sunank200 merged commit 43a4236 into main Dec 28, 2022
@sunank200 sunank200 deleted the loadfile-fix branch December 28, 2022 19:14
@kaxil kaxil added this to the 1.4.0 milestone Dec 28, 2022
sunank200 added a commit that referenced this pull request Dec 29, 2022
# Description
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
Currently `create_file_location` is picking module path based on
`filetype.value` even tough the `conn_id` is passed.
https://github.com/astronomer/astro-sdk/blob/main/python-sdk/src/astro/files/locations/__init__.py#L23
get_location_type doesn't take care of fetching the filelocation based
on `conn_type` as per `conn_id` at all. It just picks up from the path.

<!--
Issues are required for both bug fixes and features.
Reference it using one of the following:

closes: #ISSUE
related: #ISSUE
-->
closes: #1471 


## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->
- Add `validate_conn()` in BaseFilelocation class to match file path and
connection type

## Does this introduce a breaking change?
No

### Checklist
- [x] Created tests which fail without the change (if possible)
- [x] Extended the README / documentation, if necessary

Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com>
utkarsharma2 pushed a commit that referenced this pull request Jan 17, 2023
# Description
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
Currently `create_file_location` is picking module path based on
`filetype.value` even tough the `conn_id` is passed.
https://github.com/astronomer/astro-sdk/blob/main/python-sdk/src/astro/files/locations/__init__.py#L23
get_location_type doesn't take care of fetching the filelocation based
on `conn_type` as per `conn_id` at all. It just picks up from the path.

<!--
Issues are required for both bug fixes and features.
Reference it using one of the following:

closes: #ISSUE
related: #ISSUE
-->
closes: #1471 


## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->
- Add `validate_conn()` in BaseFilelocation class to match file path and
connection type

## Does this introduce a breaking change?
No

### Checklist
- [x] Created tests which fail without the change (if possible)
- [x] Extended the README / documentation, if necessary

Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com>
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.

Loadfile should also check for conn_type of conn_id provided
4 participants