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

Migrate from '...requirements.txt' to 'pyproject.toml' #1584

Closed
wants to merge 16 commits into from

Conversation

MehdiNV
Copy link
Contributor

@MehdiNV MehdiNV commented Oct 16, 2023

Description

Draft PR, TBA

Resolves #1527

What's missing for the Draft PR?

  • Making sure that setup.py has a 'package_data' parameter value passed into it

TL:DR

TBC

Development notes

TBC

QA notes

TBC

What's next?

TBC

package/setup.py Outdated Show resolved Hide resolved
@tynandebold tynandebold changed the title Issue #1521: Migrate from '...requirements.txt' to 'pyproject.toml' Migrate from '...requirements.txt' to 'pyproject.toml' Oct 16, 2023
exclude=["tests*", "features*"]

[tool.setuptools.dynamic]
readme = {file = "README.md", content-type = "text/markdown"}
Copy link
Contributor

Choose a reason for hiding this comment

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

unable to read the README file as it is in a different directory. We need to consider following the directory structure of other kedro-plugins to be consistent since kedro-viz is also a plugin.

@rashidakanchwala @noklam

Our directory structure - kedro-viz/package/kedro_viz
Other plugins have (example) - kedro-telemetry/kedro_telemetry .

Is it better we restructure our directory structure to kedro-viz/kedro_viz ?

Copy link
Member

Choose a reason for hiding this comment

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

It's tricky in your case because there's a separation between the backend and the frontend 🤔 ../README.md doesn't work?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes it throws an error saying toml cannot access any files outside the directory it is in

Copy link
Member

Choose a reason for hiding this comment

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

you can use setup.py for reading the README.md, then setuptools will merge whatever is on setup.py with pyproject.toml. see what kedro-datasets does for example

install_requires=requires,
keywords="pipelines, machine learning, data pipelines, data science, data engineering, visualisation",
author="Kedro",
packages=find_packages(exclude=["tests*", "features*"]),
package_data={"kedro_viz": list(files)},
Copy link
Contributor

Choose a reason for hiding this comment

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

@MehdiNV I tested removing the package_data and also deleted the setup.py, setup.cfg completely. I was able to install editable package via pip install -e package and also was able to run kedro viz. I am not sure where the jsbuild is used tbh.

@astrojuanlu - is the jsbuild used during publishing the package ? We execute the command make package and the below script runs -

package:
	find . -regex ".*/__pycache__" -exec rm -rf {} +
	find . -regex ".*\.egg-info" -exec rm -rf {} +
	test -f package/kedro_viz/html/index.html || (echo "Built npm package not found; packaging process cancelled."; exit 1)
	cd package && python setup.py clean --all
	cd package && python setup.py sdist bdist_wheel

@MehdiNV we might need to change these steps as well if we get rid of setup.py completely

@astrojuanlu - how can we test if the migration is success, apart from installing the package locally ? We also need to test the make package command works and the package includes everything as before ?

Thank you

Copy link
Contributor Author

@MehdiNV MehdiNV Oct 20, 2023

Choose a reason for hiding this comment

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

@ravi-kumar-pilla I think setup.py is only needed as a fallback for users who cannot utilise pyproject.toml for one reason or another (see stackoverflow post on it), what do you think about keeping it as a plan B? Or perhaps it's not necessary as it's very unlikely a user will have incompatability w/ .toml?

Overall from reading it, it seems that setup.py and others are just complementary parts to .toml - if toml setup fails, then setup.py acts as a fallback in its place for those who just have incompatible systems.

Copy link
Contributor

@ravi-kumar-pilla ravi-kumar-pilla Oct 20, 2023

Choose a reason for hiding this comment

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

I think we can migrate the requirements.txt, test_requirements.txt, setup.cfg and part of setup.py (excluding the readme and package data) to pyproject.toml. I want to discover more on this and see how can we test the setup locally and how it affects our release process of make package I mentioned above. Will work on this today ! I feel we can have both pyproject.toml and setup.py similar to the kedro team

Copy link
Member

Choose a reason for hiding this comment

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

I think the way to test if the migration is successful is producing the final .tar.gz and .whl files that go to https://pypi.org/project/kedro-viz/#files, with and without this PR, and making sure that the relevant files are identical

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @astrojuanlu ,

Thank you for the input. I tested them and they seem to be the same. I have a question on installing dependencies.

Previously when we used to install dependencies of kedro-viz via requirements.txt file, kedro-viz was not installed as a package. However, when installing the same dependencies via pyproject.toml, the list of installed dependencies contain kedro-viz.

I checked this for kedro-datasets and even kedro-datasets get installed as dependency when we install its dependencies from pyproject.toml. Is this normal ?

Thank you

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are not moving to pyproject.toml completely, I do not see why this migration is needed. For handling the caveat mentioned, I feel we should go by the option - Configure dependabot to use widen. and migrate to pyproject.toml when the ticket pypa/pip#11440 is merged. What do you think of this approach ? @astrojuanlu @tynandebold

Copy link
Member

Choose a reason for hiding this comment

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

I'm supportive of that 👍🏽

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^ This makes sense; the .toml file is now linked to a requirements.txt file containing the dependencies, however I've kept the test_requirements.txt file deleted (installing test dependencies is via .toml).

In my head, a user should have no need for the test-dependencies unless they need to use / install kedro-viz as well (in which case, they'd use the .toml fully anyway). Is this a suitable approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

@MehdiNV we will not go ahead with this draft PR. Instead, we will use the option of Configuring dependabot to use widen. to handle - #1582 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh makes sense; apologies, I hadn't reloaded the page before so hadn't seen the new comments in the last hour when I was replying. Will shift towards the widen option then - will close this PR in the meantime as it's redundant

@MehdiNV MehdiNV closed this Oct 24, 2023
@astrojuanlu
Copy link
Member

If I may, migrating from setup.py to pyproject.toml, even if it's partially, is still worth it. But you're right that if you want to keep requirements.txt around to be able to install only the dependencies, it's not as useful.

@astrojuanlu astrojuanlu mentioned this pull request Jan 15, 2024
1 task
@astrojuanlu astrojuanlu mentioned this pull request Feb 26, 2024
5 tasks
@ravi-kumar-pilla ravi-kumar-pilla deleted the feature/pyproject-toml-migration branch May 9, 2024 21:16
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.

Move to pyproject.toml
3 participants