-
Notifications
You must be signed in to change notification settings - Fork 0
formulate like a pkg #12
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
Conversation
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.
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): |
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.
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}", |
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.
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: |
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.
What's the diff between this entry point, and the one defined in pyproject.toml?
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.
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
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 don't know much about packaging, so whatever you do, is prob best.
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
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.
@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
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.
Once you add it, we can publish a test prerelease and then yank it
.github/workflows/test.yaml
Outdated
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] |
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.
note to self ther ubuntu runner 22.04 only support 3.8+
.github/workflows/lint.yaml
Outdated
if: ${{ matrix.linter == 'pylint' }} | ||
name: Lint with pylint | ||
run: | | ||
pylint $(find cacts/ -name "*.py" | xargs) |
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.
@bartgol pylint and flake8 can be pretty annoying, so please take a look at the output of their complaints before approving this PR LOL
@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 |
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.
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() |
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.
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.
avail_machs = machine_specs.keys() | |
avail_machs = machines_specs.keys() |
Copilot uses AI. Check for mistakes.
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 like a legit typo? @bartgol
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.
Will fix in another PR. I have to fix cdash submission anyways.
1e4203d
to
d669b7f
Compare
todo: