-
-
Notifications
You must be signed in to change notification settings - Fork 153
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 versioneer to setuptools_scm #1375
Conversation
55d953a
to
365daae
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1375 +/- ##
==========================================
+ Coverage 74.59% 74.69% +0.10%
==========================================
Files 196 194 -2
Lines 49813 49730 -83
Branches 10547 10527 -20
==========================================
- Hits 37157 37145 -12
+ Misses 10331 10262 -69
+ Partials 2325 2323 -2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, this looks good; just a few comments/corrections.
Aside from that, what other approaches are there for the nightly build process? It seems generating a custom pyproject.toml
could increase our maintenance overhead.
aesara/scan/op.py
Outdated
@op_debug_information.register(Scan) # type: ignore[has-type] | ||
@op_debug_information.register(Scan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine if we can somehow guarantee that we won't start seeing #1221 again; otherwise, we don't want to reintroduce it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yikes, that looks tricky! Thanks for the context. I will need to follow up here to try and understand better what's going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would really like to fix that problem at the source, but it was/is annoyingly elusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working around this by adding warn_unused_ignores = false
as below and reverting the removal of #type: ignore
, but I'll still take a stab at understanding what's really going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I haven't gotten a chance to look into this yet. The issue no longer creeps up here since readding warn_unused_ignores = false
in #1376. Is this blocking the merge?
jobs: | ||
post_checkout: | ||
# This is necessary for setuptools_scm to properly read the tags. The default | ||
# depth of 50 often leads to 'assert version is not None' AssertionError during | ||
# the pip install build process. Alternatively, we could use | ||
# 'git fetch --unshallow', but that is rather intensive. | ||
- git fetch --depth 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to understand more about this, because it seems like it could be indicative of a general issue with this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that we compute the version by looking through the git history to find the latest matching git tag. The default commands (see the RTD CI logs) download a truncated history. This command runs afterwards to download more. I chose 1000 because it's way more than I think we would ever need, and way smaller than the whole commit history. What Ida at don't understand is why it was no prob w versioneer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you still concerned about this? I think --depth 1000
is better than --unshallow
(i.e. depth=\infty) due to bandwidth/CI time considerations, and 1000 is way more than we could conceivably need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's not a real concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a vague suspicion about what might be going on here...
In case I'm working from a fork, then it's possible that my fork might not have all the tags. (Git is sometimes a bit weird about synchronizing tags, although mainly in the push direction.) Then setuptools_scm
may not have the info to compute the version.
Typing this out, it doesn't make much sense, but at some point during testing I somehow ended up installing a very "old" version of aesara simply because the tags were old. I don't have any actionable ideas, this is just something to think about.
@brandonwillard, how would you feel about first merging #1371? Otherwise this PR has lots of big commits. Thanks for the review! Looks great at first glance. Will go through it in detail now... |
Yeah, I'll look at that next. |
2879403
to
1945ad8
Compare
TODO: see if any of the pre-defined setuptools-scm formats are pushable to PyPI. If so, eliminate the nightly script. |
Details about the construction of version numbers are as follows. But this may be superfluous given the suggestion proposed in the next comment... There are two parts to a setuptools_scm version number: the "version scheme" followed by the "local scheme". These are both defined in terms of entry points, so the options are obtainable with from setuptools_scm import get_version
from importlib.metadata import entry_points
version_schemes = [
ep.name for ep in entry_points(group="setuptools_scm.version_scheme")
]
local_schemes = [
ep.name for ep in entry_points(group="setuptools_scm.local_scheme")
]
print(f"{version_schemes=}\n\nlocal_schemes={local_schemes}") version_schemes=['calver-by-date', 'guess-next-dev', 'no-guess-dev', 'post-release', 'python-simplified-semver', 'release-branch-semver']
local_schemes=['dirty-tag', 'no-local-version', 'node-and-date', 'node-and-timestamp'] To first inspect just the print(
{
version_scheme: get_version(
version_scheme=version_scheme, local_scheme="no-local-version"
)
for version_scheme in version_schemes
}
) {'calver-by-date': '22.12.25.0.dev97', 'guess-next-dev': '2.8.10.dev97', 'no-guess-dev': '2.8.9.post1.dev97', 'post-release': '2.8.9.post97', 'python-simplified-semver': '2.8.10.dev97', 'release-branch-semver': '2.9.0.dev97'} Note how all of the possibilities except for The most concise possibility is print("Clean:")
print(
{
local_scheme: get_version(
version_scheme="post-release", local_scheme=local_scheme
)
for local_scheme in local_schemes
}
)
!echo >> pyproject.toml
print("Dirty:")
print(
{
local_scheme: get_version(
version_scheme="post-release", local_scheme=local_scheme
)
for local_scheme in local_schemes
}
)
!git checkout -q pyproject.toml Clean:
{'dirty-tag': '2.8.9.post97', 'no-local-version': '2.8.9.post97', 'node-and-date': '2.8.9.post97+g1945ad8cb', 'node-and-timestamp': '2.8.9.post97+g1945ad8cb'}
Dirty:
{'dirty-tag': '2.8.9.post97+dirty', 'no-local-version': '2.8.9.post97', 'node-and-date': '2.8.9.post97+g1945ad8cb.d20221226', 'node-and-timestamp': '2.8.9.post97+g1945ad8cb.d20221226110450'} |
Why not just do Getting the version number set correctly could then be accomplished in a GH Actions workflow with a few simple Then |
Just pushed a quick implementation of the idea of my last post (only tested locally). |
a1758db
to
8ed07cd
Compare
Rebased on #1376 |
8ed07cd
to
9dae630
Compare
Rebased on main |
.github/workflows/dev-builds.yml
Outdated
curl -sSLf https://github.com/TomWright/dasel/releases/download/v2.0.2/dasel_linux_amd64 \ | ||
-L -o /tmp/dasel && chmod +x /tmp/dasel | ||
|
||
# Modify pyproject.toml to set the nightly version in the form of | ||
# x.y.z.postN, where N is the number of commits since the last release | ||
/tmp/dasel put -f pyproject.toml project.name -v aesara-nightly | ||
/tmp/dasel put -f pyproject.toml tool.setuptools_scm.version_scheme -v post-release | ||
/tmp/dasel put -f pyproject.toml tool.setuptools_scm.local_scheme -v no-local-version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks neat!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, then let's keep this in favor of the Python script-based approach. (Will squash the commit which introduces this.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Squashed. What do you think about the dev builds being called aesara-nightly
while being built on merge-to-main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good.
cfa9802
to
1c860d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. As always, it's hard to tell when/if these kinds of changes will work right away, but we can always follow up!
.github/workflows/dev-builds.yml
Outdated
curl -sSLf https://github.com/TomWright/dasel/releases/download/v2.0.2/dasel_linux_amd64 \ | ||
-L -o /tmp/dasel && chmod +x /tmp/dasel | ||
|
||
# Modify pyproject.toml to set the nightly version in the form of | ||
# x.y.z.postN, where N is the number of commits since the last release | ||
/tmp/dasel put -f pyproject.toml project.name -v aesara-nightly | ||
/tmp/dasel put -f pyproject.toml tool.setuptools_scm.version_scheme -v post-release | ||
/tmp/dasel put -f pyproject.toml tool.setuptools_scm.local_scheme -v no-local-version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good.
jobs: | ||
post_checkout: | ||
# This is necessary for setuptools_scm to properly read the tags. The default | ||
# depth of 50 often leads to 'assert version is not None' AssertionError during | ||
# the pip install build process. Alternatively, we could use | ||
# 'git fetch --unshallow', but that is rather intensive. | ||
- git fetch --depth 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's not a real concern.
1c860d6
to
691fe99
Compare
This requires at least one more iteration, since
Additionally, I noticed that |
a15e3e1
to
2e16eb4
Compare
Just rebased on main. All checks were green. |
One question: won't this cause issues when running the tests locally if the user hasn't built the package locally since there won't be any |
The What can however go wrong is that for an |
2e16eb4
to
a792d7a
Compare
I'm not sure what to think of this:
|
Hmm, dependabot did bump the version on the performance tests. I wonder if that has anything to do with it. On the other hand, the benchmarks succeeded in #1384. Maybe this simply deployed to slow runners. |
Looks like it's one of the JAX benchmarks, so it could be due to a number of things (e.g. compilation, test seeding, etc.) I'll put in a PR to at least guarantee that the test data is the same every time. |
a792d7a
to
3bddb24
Compare
3bddb24
to
cf93bb6
Compare
e6af3d6
to
55d0a4d
Compare
The benchmarks failed again. I wonder if the automerge failed to properly await the coverage results and prematurely merged #1382 (comment). Since I believe I know what's wrong, I prepended a commit to this PR to hopefully fix it. @brandonwillard, do you still approve of a rebase (no squash) merge with the extra commit? |
Is it possible to rerun the "Benchmarks" test without rerunning the whole thing? |
Co-authored-by: Brandon T. Willard <971601+brandonwillard@users.noreply.github.com>
Avoids 'assert version is not None' from setuptools_scm during the pip install build process
55d0a4d
to
9d46e0f
Compare
@brandonwillard, tests were all green before rebase. Are we okay to automerge (rebase) now, given the extra commit I added for fixing coverage? |
@brandonwillard thanks, now I'm just missing an approving review. (It wouldn't allow me to self-approve this time.) |
AddendumThis PR unintentionally dropped support for |
The base of this PR is #1371. The first original commit on this branch is "Remove versioneer".
In the first commit I remove versioneer and set the version to
"TODO"
. In the second commit, I add setuptools_scm.I also attempt to correctly configure the nightly builds. I do this by running
aesara.misc.prepare_nightly_build
to modifypyproject.toml
in the nightly build, updating the following entries:This should be tested, but I'm reasonably confident that it will work properly, and I raise an error if the version number has an incorrect form.
One strange quirk which I don't quite understand is that in order to type-check
aesara.misc.prepare_nightly_build
I added thetypes-toml
package to the mypy pre-commit config, and afterwards it raised an error about an unusedtype: ignore
inaesara/scan/op.py
L3430. Removing thetype: ignore
resolved the error. 🤷♂️Thank you for opening a PR!
Here are a few important guidelines and requirements to check before your PR can be merged:
pre-commit
is installed and set up.Don't worry, your PR doesn't need to be in perfect order to submit it. As development progresses and/or reviewers request changes, you can always rewrite the history of your feature/PR branches.
If your PR is an ongoing effort and you would like to involve us in the process, simply make it a draft PR.