Skip to content

Add cli build command - #217

Merged
srivastavaprashant merged 12 commits into
mainfrom
feat/cli-entrypoints
Aug 11, 2025
Merged

srivastavaprashant merged 12 commits into
mainfrom
feat/cli-entrypoints

Conversation

@srivastavaprashant

@srivastavaprashant srivastavaprashant commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

Changes

Resolves #190

This PR adds a build command to the cli.

Checklist

  • I broke the PR down so that it contains a reasonable amount of changes for an effective review
  • I performed a self-review of my code. Amongst other things, I have commented my code in hard-to-understand areas.
  • I made corresponding changes to the documentation
  • I added tests that prove my fix is effective or that my feature works
  • I accounted for dependent changes to be merged and published in downstream modules

@srivastavaprashant
srivastavaprashant marked this pull request as ready for review August 8, 2025 09:12
@srivastavaprashant
srivastavaprashant marked this pull request as draft August 11, 2025 08:01
@srivastavaprashant
srivastavaprashant marked this pull request as ready for review August 11, 2025 08:16

@JCZuurmond JCZuurmond left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Added some clean up comments.

Main point to change is to keep the __main__.py. I recommend to rename cli.py to __main__.py.

Approving so you can move forward

@@ -1,4 +0,0 @@
from .cli import app

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please keep the main, though, you can move it to the top-level. This allows to run the cli as: python -m pg2_dataset

Comment thread src/pg2_dataset/cli.py
"""

if version:
typer.echo(f"v{__version__}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The docs suggest to use rich for prettier console logging: https://typer.tiangolo.com/tutorial/printing/#printing-and-colors.

Otherwise, I prefer plain Python logging.

Comment thread src/pg2_dataset/cli.py Outdated
typer.echo(f"v{__version__}")
raise typer.Exit()

if ctx.invoked_subcommand is None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ha, I like the explicit is None, but a "Pythonic" approach is:

Suggested change
if ctx.invoked_subcommand is None:
if not ctx.invoked_subcommand:

Does not matter IMO if we are consistent across the code base(s)

Comment thread src/pg2_dataset/cli.py Outdated
Comment on lines +57 to +59
Returns:
None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Returns:
None

Comment thread src/pg2_dataset/cli.py Outdated
Comment on lines +50 to +51
"""Creates a Dataset instance from a manifest TOML file and dumps it as zip to a
specified directory path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

First sentence should fit on one line. Also the implementation details can be hidden here, write the intent instead or add the implementation details in a first paragraph:

Suggested change
"""Creates a Dataset instance from a manifest TOML file and dumps it as zip to a
specified directory path.
"""Build a protein gym dataset.
<implementation details>

Comment thread src/pg2_dataset/cli.py Outdated
Comment on lines +54 to +55
manifest_path: The path to the manifest TOML file.
output_path: The directory path to dump the dataset archive.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
manifest_path: The path to the manifest TOML file.
output_path: The directory path to dump the dataset archive.
manifest_path (Path) : The path to the manifest TOML file.
output_path (Path | None) : The directory path to dump the dataset archive. If `None`, the current working directory is used. Defaults to `None`.

Comment thread src/pg2_dataset/cli.py Outdated
Comment on lines +27 to +28

Returns: None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Returns: None

Comment thread src/pg2_dataset/cli.py Outdated

Args:
ctx: The context for the CLI.
version: If True, show the version and exit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
version: If True, show the version and exit.
version (bool): If `True`, show the package version. Defaults to `False`.

Comment thread src/pg2_dataset/cli.py Outdated
"""Main entry point for the CLI.

Args:
ctx: The context for the CLI.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
ctx: The context for the CLI.
ctx (type.Context): The context for the CLI.

Comment thread tests/test_cli.py
assert result.exit_code == 0
assert result.stdout.startswith("v")
assert __version__ in result.stdout

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change

@srivastavaprashant
srivastavaprashant merged commit 2708907 into main Aug 11, 2025
4 checks passed
@srivastavaprashant
srivastavaprashant deleted the feat/cli-entrypoints branch August 11, 2025 11:05
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.

CLI entrypoints

2 participants