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

feat: change Makefile to generate dedicated python requirements.txt files #776

Merged
merged 16 commits into from Aug 8, 2023

Conversation

Nischay-Pro
Copy link
Contributor

Description

This PR updates the Makefile to create dedicated python version folders for each requirement.

Currently, the *.in files are generic and are used as a baseline to generate custom *.txt requirement files for every Python version we currently support.

Currently, we are targeting 3.8, 3.9, 3.10, and 3.11.

Related Items

Related to #748


  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
Copy link
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

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

Very cool!

I believe we also should use the fitting .txt requirements (for the Python version used there) in Dockerfile, line 15.

In the end, there seems to be no difference currently in the actually-installed versions, see below (just Python3.8 requiring a few more). How were these .txt files generated? With make freeze-deps or make upgrade-deps?

± diff requirements/3.11/app.txt requirements/3.8/app.txt 
2c2
< # This file is autogenerated by pip-compile with Python 3.11
---
> # This file is autogenerated by pip-compile with Python 3.8
12a13,14
> async-timeout==4.0.2
>     # via redis
16a19,20
> backports-zoneinfo==0.2.1
>     # via workalendar
119a124,125
>     #   alembic
>     #   flask
120a127,131
> importlib-resources==6.0.0
>     # via
>     #   alembic
>     #   jsonschema
>     #   matplotlib
210a222,223
> pkgutil-resolve-name==1.3.10
>     # via jsonschema
250a264
>     #   babel
320a335
>     #   altair
349c364,366
<     # via importlib-metadata
---
>     # via
>     #   importlib-metadata
>     #   importlib-resources

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@Nischay-Pro
Copy link
Contributor Author

For that I just ran make install-for-dev to create the dep text files.

Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
@Nischay-Pro Nischay-Pro marked this pull request as ready for review July 27, 2023 23:48
Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
Copy link
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

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

Looking good.

Can you also update the Dockerfile like I asked in the last review?

Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
@nhoening
Copy link
Contributor

Does this PR depend on #771 ?

@Nischay-Pro
Copy link
Contributor Author

Does this PR depend on #771 ?

Yes. We need to bump up the pip-tools version for it to work on Python 3.11

Else we will get getting the following error.

ImportError: cannot import name 'BAR_TYPES' from 'pip._internal.cli.progress_bars' (/opt/miniconda3/envs/flexmeasures-3.11-test/lib/python3.11/site-packages/pip/_internal/cli/progress_bars.py)
make[1]: *** [Makefile:82: freeze-deps] Error 1
make[1]: Leaving directory '/home/nischay/Git/flexmeasures'
make: *** [Makefile:41: install-for-dev] Error 2

@nhoening
Copy link
Contributor

Then we should work on merging that other PR first.

Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
requirements/dev.in Outdated Show resolved Hide resolved
requirements/test.in Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@nhoening nhoening mentioned this pull request Aug 1, 2023
2 tasks
Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
@Nischay-Pro
Copy link
Contributor Author

We cannot merge this PR yet. The tests for Python 3.8 do not pass.

I am getting the following error when trying to run tests

/opt/miniconda3/envs/flexmeasures-3.8-test/lib/python3.8/site-packages/_pytest/config/__init__.py:642: in _importconftest
    mod = import_path(conftestpath, mode=importmode, root=rootpath)
/opt/miniconda3/envs/flexmeasures-3.8-test/lib/python3.8/site-packages/_pytest/pathlib.py:565: in import_path
    importlib.import_module(module_name)
/opt/miniconda3/envs/flexmeasures-3.8-test/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
/opt/miniconda3/envs/flexmeasures-3.8-test/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
flexmeasures/api/dev/tests/conftest.py:3: in <module>
    from flexmeasures.api.v3_0.tests.conftest import add_incineration_line
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
/opt/miniconda3/envs/flexmeasures-3.8-test/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
flexmeasures/api/v3_0/tests/conftest.py:15: in <module>
    ) -> dict[str, Sensor]:
E   TypeError: 'type' object is not subscriptable
collected 0 items / 1 error

@nhoening
Copy link
Contributor

nhoening commented Aug 3, 2023

@Flix6x here is another case where type annotations give problems for 3.8. Adding from __future__ import annotations at the top would solve this right?

Great that we now explicitly test what works. This PR helps with that.

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: Nischay Ram Mamidi <NischayPro@gmail.com>
@Nischay-Pro
Copy link
Contributor Author

All tests pass for Python versioned 3.8 to 3.11

Copy link
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

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

Great. I want to merge this soon and are if the GitHub Action pipeline will work as we want.
But it would be smart to first release 0.15.

And for that I want you to make another small PR with the two future imports and nothing else. I would then merge that one right away.

This is to make sure that 0.15 is compatible with Python 3.8, and that we could easily leave this PR out of the release if we need to.

Copy link
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

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

Ah sorry, I thought the GitHub pipeline with a matrix is done here as well, but that is a follow-up PR.

Could you still make the small 3.8 compatibility PR? It's cleaner.

For merging this, I only ask that we do a quick build of the Docker image.

@nhoening
Copy link
Contributor

nhoening commented Aug 7, 2023

I can confirm this branch fixes the currently broken building of the Docker image (due to the pint dependency).

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…be more in line with other naming of dependency handling

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Nischay-Pro and others added 2 commits August 7, 2023 14:44
@nhoening nhoening merged commit b6687a4 into main Aug 8, 2023
5 checks passed
@nhoening nhoening deleted the split-requirements branch August 8, 2023 07:33
nhoening added a commit that referenced this pull request Aug 8, 2023
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@Flix6x Flix6x added this to the 0.15.0 milestone Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants