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

Version management update #1696

Merged
merged 9 commits into from Mar 21, 2024
Merged

Version management update #1696

merged 9 commits into from Mar 21, 2024

Conversation

bennibbelink
Copy link
Contributor

This PR automates the process of setting the version number throughout the code.

  • src/version.h is now generated so that CMake can set the version numbers during the build
  • setup.py fixed the regex so it replaces the version string in __init__.py. (also maybe we want to modify the hardcoded string in __init__.py so that it doesn't always say 1.5.5)
  • added core_version as a build arg in the Dockerfiles
  • modified publish_release.yml to pass in the core_version build arg so that when we publish packages they use the correct version

@bennibbelink bennibbelink marked this pull request as ready for review March 13, 2024 19:21
Copy link

Downstream Build Status Report

Build FROM cyclus_20.04_apt/cyclus
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_20.04_conda/cyclus
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_22.04_apt/cyclus
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_22.04_conda/cyclus
  • Cycamore: Success
  • Cymetric: Success

@coveralls
Copy link
Collaborator

coveralls commented Mar 13, 2024

Pull Request Test Coverage Report for Build 8380326460

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 15 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.005%) to 32.594%

Files with Coverage Reduction New Missed Lines %
src/toolkit/res_buf.h 1 58.53%
src/resource.h 3 41.27%
tests/toolkit/res_buf_tests.h 5 55.0%
src/context.cc 6 54.52%
Totals Coverage Status
Change from base Build 8255130199: 0.005%
Covered Lines: 53047
Relevant Lines: 129057

💛 - Coveralls

@gonuke
Copy link
Member

gonuke commented Mar 13, 2024

I don't think these version strings all mean the same thing... we probably need to discuss

@gonuke
Copy link
Member

gonuke commented Mar 14, 2024

I'll have to look into it, but there is a release version that is set in a file and there is the version number we provide at build time.

@gonuke
Copy link
Member

gonuke commented Mar 14, 2024

I think (??) the version at build time specifies which version of the data model to build whereas the one in the version.h file is the code version. The challenge is to remember if/how/why/when these are different.

@bennibbelink
Copy link
Contributor Author

Are you referring to the data model in share/dbtypes.json?

@bennibbelink
Copy link
Contributor Author

bennibbelink commented Mar 14, 2024

Found this PR, trying to get a handle on the process

EDIT: Also this Release Procedure and this Release repo

@bennibbelink
Copy link
Contributor Author

This is my understanding of share/dbtypes.json.in:

  • It is used to maintain a version history of the data model - so if one wanted to build cyclus with an older data model they could specify --core-version=x.x and cyclus would use the appropriate data model
  • If cyclus is built with a version greater than what exists in share/dbtypes.json.in it will generate a new data model using the core version passed into the build. This generated data model just copies the latest data model that exists in share/dbtypes.json.in (I think)
  • with each release share/dbtypes.json.in should be manually updated to reflect the data model for the release candidate version (old PR convo). If there were no changes made, this should be as easy as copying relevant sections from the generated share/dbtypes.json (note no .in) to share/dbtypes.json.in

If these notes are correct (and align with your memory @gonuke), I think the changes in this PR are still appropriate improvements to automate the version propagation throughout the code at build-time.

However... if these notes are correct then it appears that when cyclus v1.5 was released share/dbtypes.json.in was not manually updated to reflect the new data model for v1.5 since the latest model in that file is v1.4 (I'm assuming there were no changes between the two versions otherwise things probably would have broken). What is the best way to move forward? Add the model for v1.5 to main before we make a release candidate, then add the model for our release candidate in the release candidate branch?

P.S. What will the next release be - v1.6.0 or v2.0.0?

@gonuke
Copy link
Member

gonuke commented Mar 20, 2024

I can't contest your interpretation, although I can't recall if there was an expectation of appending/extending dtypes.json.in with a new data model version if it didn't change, or just relying on the latest one that existed in that case??

One thing that still concerns me about this is that the source code will no longer document the release number upon release. It will be embedded in the docker image that publish_release.yml generates via the GitHub release tag, but if someone downloaded the source code and installed it, the release number would exist nowhere.

@bennibbelink
Copy link
Contributor Author

I can't contest your interpretation, although I can't recall if there was an expectation of appending/extending dtypes.json.in with a new data model version if it didn't change, or just relying on the latest one that existed in that case??

Maybe things changed since this comment (and I don't see anything in the doc/ directory about this, is there a different docs repo?) but it sounds like it should be extended on every release. I will dig around to confirm/deny this suspicion.

One thing that still concerns me about this is that the source code will no longer document the release number upon release. It will be embedded in the docker image that publish_release.yml generates via the GitHub release tag, but if someone downloaded the source code and installed it, the release number would exist nowhere.

Fair point. One clarifying question: if a user downloads source code and installs using the hardcoded version number, don't they need to pass the correct build arg for --core-version when building cyclus? I believe this argument is mainly used in the CMake build to generate dbtypes.json. Why pass this in as a parameter? If a user wanted to use an older data model then they would also have to go into version.h and manually change the hardcoded version anyway (I think). We may want to take a step back and rethink the versioning system. (possibly a combination of the current method and this PR.... Have a config file with a hardcoded version and then use CMake to populate the appropriate source code files?)

@bennibbelink
Copy link
Contributor Author

Summary of the different versions and their locations in Cyclus:

src/hdf5_back_gen.py

  • uses core_version passed into CMake
  • reads data model from share/dbtypes.json
  • build fails in this file if I pass in 1.3 or 1.4 as --core-version
  • lines 2772-2779 imply that this uses the highest data model version it can find (bug? Whats the point of maintaining old data models if they never get used)

share/dbtypes_gen.py

  • generates data model for version even if it already exists (I passed in 1.3 and it generated a second v1.3 model after the v1.4 model)
  • generates data model directly from the comments in src/query_backend.h

src/version.cc(.in)

  • describe() returns the version passed in as --core-version
  • core() returns the version hardcoded in src/version.h
  • cyclus --version returns "Cyclus Core <core()> (<describe()>)"

Some general impressions I have:

  • We can change the version in src/version.h with seemingly no repercussions
  • The data model version we use doesn't seem to matter?? It will get generated from the comments in src/query_backend.h regardless of what we pass in... passing in older versions just seems to break the build (which might be a result of the bug(?) in src/hdf5_back_gen.py)

We can talk about this in-person tomorrow but I wanted to get these notes down somewhere.

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

A couple of final clarifying comments

CMakeLists.txt Outdated Show resolved Hide resolved
@@ -2,8 +2,8 @@
# Runs setup.py install
#
set(PYTHON_EXECUTABLE @Python3_EXECUTABLE@)
set(core_version @core_version@)
set(ENV{CYCLUS_CORE_VERSION} "${core_version}")
set(CYCLUS_CORE_VERSION @CMAKE_PROJECT_VERSION@)
Copy link
Member

Choose a reason for hiding this comment

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

If a user specifies core_version during setup, shouldn't we use that still?

Copy link
Member

Choose a reason for hiding this comment

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

and don't we now set CYCLUS_CORE_VERSION reliably at the top level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored build to differentiate between CMAKE_PROJECT_VERSION(CYCLUS_PROJECT_VERSION in setup.py) and DATA_MODEL_VERSION

@bennibbelink
Copy link
Contributor Author

I had to update tests/test_cycluslib.py and tests/tools.py to correctly set up the tests. Not sure why this started failing now, my best guess is that new versions of pytest removed the functionality we were previously relying on

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

two more naming cleanup suggestions

CMakeLists.txt Outdated Show resolved Hide resolved
@@ -10,7 +10,7 @@ INCLUDE_DIRECTORIES(${CYCLUS_CORE_INCLUDE_DIRS})
message(STATUS "Generating Type System API for Python")
EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/gentypesystem.py
"--src-dir=${CMAKE_CURRENT_SOURCE_DIR}"
"--cyclus-version=${core_version}"
"--cyclus-version=${DATA_MODEL_VERSION}"
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 want to change this argparse variable for gentypesystem.py?

Suggested change
"--cyclus-version=${DATA_MODEL_VERSION}"
"--data-model-version=${DATA_MODEL_VERSION}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed this. At some point (maybe not right now) should we rename version::core() or keep it as is? As is, version::core() is the "source code version" and version::describe() is the "data model version"

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 hold off on this for now

bennibbelink and others added 2 commits March 21, 2024 13:54
Co-authored-by: Paul Wilson <paul.wilson@wisc.edu>
Signed-off-by: bennibbelink <79653949+bennibbelink@users.noreply.github.com>
Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

LGTM - will merge following successful tests

@bennibbelink
Copy link
Contributor Author

After merge are we ready to make a release candidate branch? http://fuelcycle.org/cep/cep3.html#release-candidates-tags-branches

Related: CEP 3 dictates we make release candidates for all 3 projects, I will implement a similar versioning strategy in cycamore so it is ready for release as well. Should be much more straightforward than cyclus

@gonuke gonuke merged commit 68ef954 into main Mar 21, 2024
23 checks passed
@bennibbelink bennibbelink deleted the version-update branch March 21, 2024 23:08
@bennibbelink bennibbelink mentioned this pull request Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants