Skip to content

Conversation

mahf708
Copy link
Collaborator

@mahf708 mahf708 commented Apr 23, 2025

todo:

  • add hatching and init
  • add dynamic versioning and --version argparse stuff
  • add skeleton for ci (testing, docs, pypi publishing, litning, etc.)

@mahf708 mahf708 requested review from bartgol and Copilot April 23, 2025 22:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors project configuration and entry point settings while introducing dynamic versioning and updating the command line interface. Key changes include updating pyproject.toml to use dynamic versioning with Hatch, modifying the entry point from "cacts.cacts:main" to "cacts:main", and updating the signature of parse_command_line in cacts/cacts.py to accept a version parameter.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Removed static version and related keys; added dynamic versioning and updated script entry
cacts/cacts.py Updated main() to import version and modified parse_command_line signature
cacts/init.py Added version and a main() function redirecting to the new entry point
Files not reviewed (1)
  • readme: Language not supported
Comments suppressed due to low confidence (1)

pyproject.toml:22

  • Confirm that the updated entry point 'cacts:main' correctly reflects the new module structure and avoids any ambiguity compared to the previous 'cacts.cacts:main'.
cacts = "cacts:main"

@@ -577,7 +576,7 @@ def parse_config_file(self,config_file,machine_name,builds_types):
self._builds.append(build)

###############################################################################
def parse_command_line(args, description):
def parse_command_line(args, description, version):
Copy link
Preview

Copilot AI Apr 23, 2025

Choose a reason for hiding this comment

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

Ensure that all invocations of parse_command_line include the version parameter so that the --version argument works as expected and to avoid potential runtime errors.

Copilot uses AI. Check for mistakes.

@@ -635,4 +634,7 @@ def parse_command_line(args, description):
parser.add_argument("-v", "--verbose", action="store_true",
help="Print output of config/build/test phases as they would be printed by running them manually.")

parser.add_argument("--version", action="version", version=f"%(prog)s {version}",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does argparse handle the "print and exit" part? I don't see any logic in our code otherwise...


__version__ = "0.1.0"

def main() -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the diff between this entry point, and the one defined in pyproject.toml?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main entry point should come from the top level, that's the thinking...

In the future, we could have additional cli stuff:

  • the main (current) will be cacti ...
  • in the future, we can have cacti-xyz ...

I would prefer we expose the main one through the top level. But functionally, there's zero difference

bartgol
bartgol previously approved these changes Apr 23, 2025
Copy link
Collaborator

@bartgol bartgol left a comment

Choose a reason for hiding this comment

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

I don't know much about packaging, so whatever you do, is prob best.

@mahf708 mahf708 requested a review from bartgol April 23, 2025 23:10
@mahf708 mahf708 dismissed bartgol’s stale review April 23, 2025 23:11

premature approval lol

uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bartgol we just need this. Basically, need the token from pypi, then we save it inside this repo as "PYPI_API_TOKEN" in the repo settings secrets/ actions/ space

See here for details: https://github.com/marketplace/actions/pypi-publish#usage

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Once you add it, we can publish a test prerelease and then yank it

strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note to self ther ubuntu runner 22.04 only support 3.8+

if: ${{ matrix.linter == 'pylint' }}
name: Lint with pylint
run: |
pylint $(find cacts/ -name "*.py" | xargs)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bartgol pylint and flake8 can be pretty annoying, so please take a look at the output of their complaints before approving this PR LOL

@bartgol
Copy link
Collaborator

bartgol commented Apr 24, 2025

@mahf708 what do you want to do with the py testing? Since only 3.8+ is avail, should we just rm 3.6/3.7? Of course, since CIME requires 3.6 (I think), it would be nice to test with 3.6...

@mahf708
Copy link
Collaborator Author

mahf708 commented Apr 24, 2025

@mahf708 what do you want to do with the py testing? Since only 3.8+ is avail, should we just rm 3.6/3.7? Of course, since CIME requires 3.6 (I think), it would be nice to test with 3.6...

let's see if running on ubuntu-20.04 will make a diff... [edit no, that's gone ... we can use some other mechanism to get 3.6, but not sure it is worth it tbh]

btw, I am going to take out those linters for now, and we can add them later. They will format most of the code... which is something I don't want us to do right now

@mahf708 mahf708 marked this pull request as ready for review April 24, 2025 15:44
@mahf708 mahf708 requested review from Copilot and bartgol April 24, 2025 15:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements dynamic versioning, updates the build configuration (switching to hatchling), and adds CI skeleton workflows.

  • Updated pyproject.toml for dynamic versioning and a hatchling build backend.
  • Improved error handling and module imports in utility and command-line parsing code.
  • Added GitHub Actions workflows for testing and package publishing.

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyproject.toml Revised project metadata, dynamic versioning, and build system settings.
cacts/utils.py Modified the default exception type in the expect function.
cacts/machine.py Updated Machine class initialization and variable naming.
cacts/cacts.py Refactored command-line parsing and version import to resolve circular imports.
cacts/tests/noop_test.py Added a basic test to ensure pytest runs.
.github/workflows/*.yaml Introduced CI workflows for testing and PyPI publishing.
Files not reviewed (1)
  • readme: Language not supported
Comments suppressed due to low confidence (1)

cacts/cacts.py:644

  • The function 'get_current_commit()' appears undefined (consider using 'get_current_sha()') and the code following the 'return' statement is unreachable.
sha = get_current_commit()

else:
expect (name in machines_specs.keys(),
avail_machs = machine_specs.keys()
Copy link
Preview

Copilot AI Apr 24, 2025

Choose a reason for hiding this comment

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

The variable 'machine_specs' is likely a typo; it should be 'machines_specs' to match the constructor parameter, which may lead to a runtime error.

Suggested change
avail_machs = machine_specs.keys()
avail_machs = machines_specs.keys()

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

@mahf708 mahf708 Apr 24, 2025

Choose a reason for hiding this comment

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

this looks like a legit typo? @bartgol

Copy link
Collaborator

Choose a reason for hiding this comment

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

Will fix in another PR. I have to fix cdash submission anyways.

@mahf708 mahf708 merged commit 86fab2c into main Apr 24, 2025
8 checks passed
@mahf708 mahf708 deleted the mahf708/pkgmania branch April 24, 2025 16:32
This was referenced Jul 30, 2025
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