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

Package build improvements: #181

Merged
merged 38 commits into from
Jan 6, 2024
Merged

Conversation

wraymo
Copy link
Contributor

@wraymo wraymo commented Dec 13, 2023

  • Replace packager with Taskfile to reduce complexity and support incremental builds.
  • Use poetry to build Python components.

Description

The package is currently built using a Python script (the so-called "packager") which has no support for incremental builds. In addition, the way we install the Python components into the package is quite hacky and doesn't take advantage of Python's packaging tools.

This PR adds support for building the Python components using poetry and replaces the packager tool with a Taskfile (see Task). The Taskfile allows us to track changes to source files and only rebuild artifacts that depend on the changed source files.

One limitation of this PR (compared to the original packager) is that we haven't added support for automatically building the package in a container. As a result, users of this new build flow will need to setup a build machine/container manually. We hope to resolve this in a future PR.

Validation performed

  • Passed yamllint
  • Successfully built the package using Task
  • Validated compression and search with the hive-24hrs dataset.

Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

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

A quick review (we will need another iteration after this). Some high-level comments as well:

  • You're missing the validation section of the PR?
  • You should add the build folder of each component to .gitignore
  • The taskfile replaces the packager so we should ensure they generate the same output (from a user's perspective) and that we remove unnecessary files/docs, etc.

BUILDING.md Outdated
Comment on lines 3 to 4
* [Meteor](https://docs.meteor.com/install.html#installation)
* [NodeJS 14](https://nodejs.org/download/release/v14.21.3/)
Copy link
Member

Choose a reason for hiding this comment

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

Meteor and NodeJS aren't requirements right now.

BUILDING.md Outdated
* Run `task` from the root of the project
* The package will be available at `out/clp-package`

NOTE: The taskfile is not set up perfectly so it's possible it may generate an
Copy link
Member

Choose a reason for hiding this comment

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

We should address this limitation in this PR.

BUILDING.md Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This doc should be in docs/Building.md.

Comment on lines 16 to 20
[tool.poetry.group.dev.dependencies]
black = "^23.9.1"
docformatter = "^1.7.5"
mypy = "^1.5.1"
ruff = "^0.0.291"
Copy link
Member

Choose a reason for hiding this comment

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

Let's add these dev dependencies in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

requirements.txt Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Do we need these? Shouldn't this all be handled in the taskfile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need poetry to build Python packages.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, sorry, I forgot how the Taskfile was using this.


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Copy link
Member

Choose a reason for hiding this comment

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

Missing empty line at end of file.

components/clp-py-utils/pyproject.toml Outdated Show resolved Hide resolved
Taskfile.yml Outdated
cmds:
- rm -rf {{.CLP_BUILD_DIR}}/clp-package

# TODO Clean-up
Copy link
Member

Choose a reason for hiding this comment

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

Should get rid of the TODO.

Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

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

I have changes locally that I will commit once I clean them up, but in the mean time:

  • You're still missing the validation section of the PR?
  • For the Python components, we don't need the constraints.txt and requirements.txt files since we're now using pyproject.toml
  • Similarly, in the Python component READMEs, the instructions should be about how to build and install with poetry.

Taskfile.yml Show resolved Hide resolved
@@ -0,0 +1,10 @@
# CLP Package Utilities

This python module contains utilities used by thegit CLP package.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This python module contains utilities used by thegit CLP package.
This python module contains utilities used by the CLP package.

requirements.txt Outdated
Copy link
Member

Choose a reason for hiding this comment

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

To ensure reproducible builds, let's lock the versions of these packages.

@wraymo wraymo force-pushed the package_prototype branch from 79264ec to 4eb5bfd Compare January 3, 2024 16:44
Copy link
Contributor Author

@wraymo wraymo left a comment

Choose a reason for hiding this comment

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

Looks good to me

@wraymo wraymo force-pushed the package_prototype branch from 20bbea3 to 7c66428 Compare January 6, 2024 04:32
@kirkrodrigues kirkrodrigues merged commit 9f839c4 into y-scope:main Jan 6, 2024
5 checks passed
@kirkrodrigues kirkrodrigues changed the title Use Task to build the project Package build improvements: Jan 6, 2024
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.

2 participants