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

Manage dependencies #113

Merged
merged 20 commits into from
Feb 22, 2022
Merged

Manage dependencies #113

merged 20 commits into from
Feb 22, 2022

Conversation

utkarsharma2
Copy link
Collaborator

@utkarsharma2 utkarsharma2 commented Feb 16, 2022

  1. Added conditional imports to manage import errors due potential package absence.
  2. Updated pyproject.toml to move packages to optional packages. Choose Postgres as default db for time being till we have support for sqlite.

Resolves #82

@utkarsharma2
Copy link
Collaborator Author

@dimberman @tatiana - Do you guys have any suggestion to test this with UT?

@utkarsharma2 utkarsharma2 marked this pull request as draft February 16, 2022 15:27
"SQLAlchemy==1.3.24",
"sqlalchemy-bigquery==1.3.0"
"apache-airflow-providers-postgres",
Copy link
Member

@uranusjr uranusjr Feb 17, 2022

Choose a reason for hiding this comment

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

If a user needs Postgres support, they’d install astro[postgres] and pick up the Postgres provider from the extra, so this line shouldn’t be needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So Postgre is default DB until we have support for sqlite.

@utkarsharma2 utkarsharma2 marked this pull request as ready for review February 17, 2022 16:52
@utkarsharma2 utkarsharma2 requested a review from tatiana February 17, 2022 17:00
def __getattr__(self, item):
raise RuntimeError(
f"Error loading the module {self.module_name},"
f" please make sure all the dependencies are installed"
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think if we gave a more helpful message, telling the users how to install the missing packages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I agree, I think we can point out the command to run in error message itself.
Like then they can do pip install astro-project[aws] if package related to AWS was missing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would be awesome, @utkarsharma2 !

pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated
"s3fs",
"smart-open[s3]>=5.2.1",
]
gcs = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

it may be worth renaming gcs to gcp

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll update this.
FYI - @dimberman

@tatiana
Copy link
Collaborator

tatiana commented Feb 18, 2022

@utkarsharma2 it's great to see progress in this stream!

  1. Docs: we probably want to update the docs on how the installation changed, explaining how users installing Astro with pip can benefit from this feature. It's straightforward if we are installing locally, having the pyproject.toml, but it may be worth documenting to users downloading from PyPI using pip install astro-projects[snowflake] etc.

  2. Tests: I agree we need to find a way of testing things before merging this feature.
    A strategy could be to mock the value of some_module.__import__ so it raises ModuleNotFoundError, have you tried this?

"s3fs",
"smart-open[s3]>=5.2.1",
]
all = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

@uranusjr Does all keyword work with flit -- pypa/flit#488

I wanted to use flit for https://github.com/astronomer/astronomer-providers/ but the following two issues made me think otherwise:

Copy link
Member

Choose a reason for hiding this comment

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

The keys here can be arbitrary, everything should work. (Well, if it is a valid extra name.)

Copy link
Member

Choose a reason for hiding this comment

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

Flit currently only puts license information in trove classifiers. The license field is pending standardisation. (If we really want to we can probably extend Flit to add that field to the wheel, but the value wouldn’t be very useful due to its lack of standardisation.)

The second issue you linked is requesting a “magic” extra that’s added automatically without declaring. IMO that’s not that good an idea, but manually declaring all should work just fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you very much, @kaxil & @uranusjr , I always learn a lot from your comments!

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.

It looks great, thank you very much @utkarsharma2 !

@utkarsharma2 utkarsharma2 merged commit e76b48a into main Feb 22, 2022
utkarsharma2 added a commit that referenced this pull request Mar 30, 2022
Handled missing providers.

Co-authored-by: utkarsh sharma <utkarsharma@utkarshs-MacBook-Pro.local>
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.

Only install dependencies the user needs
4 participants