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

ExcelFileType class added #1978

Merged
merged 24 commits into from
Aug 11, 2023
Merged

ExcelFileType class added #1978

merged 24 commits into from
Aug 11, 2023

Conversation

skolchin
Copy link
Contributor

@skolchin skolchin commented Jul 2, 2023

New file type class (ExcelFileType) added to support operations on Excel files (see #1956)

@pre-commit-ci pre-commit-ci bot requested a review from a team July 2, 2023 09:46
@tatiana tatiana added the safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) label Jul 3, 2023
Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

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

Thank you very much for the contribution, @skolchin. It's looking great, including code, docs, and tests.

Minor comments in-line. I just enabled the tests, so we can confirm all the tests pass in the CI. Please, could you rebase this PR based on the latest main?

python-sdk/src/astro/constants.py Outdated Show resolved Hide resolved
python-sdk/dev/Dockerfile Outdated Show resolved Hide resolved
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.

LGTM. But look like there is a conflict and would be great if we can add a test here if possible https://github.com/astronomer/astro-sdk/blob/main/python-sdk/tests/sql/operators/test_load_file.py

@skolchin
Copy link
Contributor Author

skolchin commented Aug 9, 2023

LGTM. But look like there is a conflict and would be great if we can add a test here if possible https://github.com/astronomer/astro-sdk/blob/main/python-sdk/tests/sql/operators/test_load_file.py

@pankajastro , when I run pytest -s -v -x -k load_file in tests\sql, I'm getting an error astro.exceptions.NonExistentTableException: The table _tmp_xxx does not exist. Is this a problem you've mentioned?

@pankajastro
Copy link
Contributor

pankajastro commented Aug 9, 2023

@pankajastro , when I run pytest -s -v -x -k load_file in tests\sql, I'm getting an error astro.exceptions.NonExistentTableException: The table _tmp_xxx does not exist. Is this a problem you've mentioned?

Hi @skolchin, from log you have shared it is difficult to say why it happening. but test work on the local machine. We have some integration tests that require more setup like credentials etc.

I would suggest, maybe adding an airflow task here https://github.com/astronomer/astro-sdk/blob/main/python-sdk/example_dags/example_load_file.py would be great. We have everything in CI to run this

load_xlsv_file_in_postgres = aql.load_file(
        task_id="local_xlsv_to_postgress",
        input_file=File(path=str(CWD.parent) + "/tests/data/sample.xlsx", filetype=FileType.XLSX),
        output_table=Table(
            conn_id=ASTRO_POSTGRESS_CONN_ID,
        ),
    )

@pankajastro
Copy link
Contributor

@skolchin do let us know if you need any support on this, looks like we are very close to merging it

@pankajastro pankajastro added safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) and removed safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) labels Aug 10, 2023
@skolchin
Copy link
Contributor Author

@skolchin do let us know if you need any support on this, looks like we are very close to merging it

@pankajastro Hi, sorry, was buzy yesterday. Test added and it seems it works

@pankajastro pankajastro added safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) and removed safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) labels Aug 10, 2023
@pankajastro pankajastro added the safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) label Aug 10, 2023
@pankajastro pankajastro added safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) and removed safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) labels Aug 10, 2023
@pankajastro pankajastro added safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) and removed safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) labels Aug 10, 2023
@pankajastro pankajastro added safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) and removed safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) labels Aug 10, 2023
@pankajastro pankajastro added safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) and removed safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) labels Aug 10, 2023
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.

LGTM

@pankajastro pankajastro requested a review from tatiana August 10, 2023 22:47
@@ -0,0 +1,46 @@
from __future__ import annotations

import io
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking good. Just one thing - can we change the dir structure? if it's not too much trouble?
it can be something like:
python-sdk/src/astro/files/types/excel
python-sdk/src/astro/files/types/excel/base.py
python-sdk/src/astro/files/types/excel/xls.py
python-sdk/src/astro/files/types/excel/xlsx.py

WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought about it but some test refactoring requires

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can do it as separate PR if needed

Comment on lines 314 to +318
yield method_map_fixture(
method=method,
classes=classes,
base_path=base_path,
get=lambda x: FileType(x.rstrip(suffix).lower()),
get=lambda x: FileType(x[0:-8].lower()), # remove FileType suffix
Copy link
Collaborator

Choose a reason for hiding this comment

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

suffix = "FileType"
yield method_map_fixture(
        method=method,
        classes=classes,
        base_path=base_path,
        get=lambda x: FileType(x[0:-len(suffix)].lower()),  # remove FileType suffix

Something like this would be better, compared to 0: -8. WDYT?

Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all the feedback, @skolchin ! Looks great!

pankajastro added a commit that referenced this pull request Aug 11, 2023
main branch is broken see CI
https://github.com/astronomer/astro-sdk/actions/runs/5830707808/job/15812653210
I had added a ignore in
#1978 but for quick merge
creating separate PR
@pankajastro pankajastro added safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) and removed safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution) labels Aug 11, 2023
@pankajastro pankajastro merged commit 319201e into astronomer:main Aug 11, 2023
@pankajastro
Copy link
Contributor

This is awesome, thanks @skolchin 👏 for creating the PR. Appreciate it.

@pankajastro pankajastro mentioned this pull request Aug 11, 2023
9 tasks
@skolchin
Copy link
Contributor Author

@pankajastro @tatiana thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test Adding this label to a PR, will allow running all the tests in CI. (use it with caution)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants