Skip to content

Feature: Allow to use prime-cli in python as package #16

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

JannikSt
Copy link
Member

@JannikSt JannikSt commented Jan 9, 2025

No description provided.

@JannikSt JannikSt added the enhancement New feature or request label Jan 9, 2025
@JannikSt JannikSt requested a review from Copilot May 5, 2025 21:28
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 enables the prime‑cli package to be used directly in Python by exposing API functions and adding a version callback, along with updating the README for Python usage.

  • Added a new version_callback function in main.py for version display.
  • Updated init.py to dynamically retrieve the package version and expose API functions.
  • Provided a Python usage example in examples/list-pods.py and updated the README accordingly.

Reviewed Changes

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

File Description
src/prime_cli/main.py Introduces version_callback to handle version output in CLI.
src/prime_cli/init.py Updates module initialization with dynamic versioning and API setup.
examples/list-pods.py Adds a simple example to demonstrate Python usage of the package.
README.md Modifies usage and development instructions to include Python usage.

@JannikSt JannikSt requested a review from Copilot May 5, 2025 21:30
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 enables prime-cli to be used as a package in Python by exposing key functionality through module-level functions and establishing API client instances on import.

  • Introduces dynamic version retrieval via importlib.metadata
  • Adds function wrappers for API key configuration, pod management, and GPU availability
  • Updates documentation and example usage in both the README and examples directory

Reviewed Changes

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

File Description
src/prime_cli/init.py Initializes package-level API clients and provides utility methods
examples/list-pods.py Adds an example script demonstrating basic usage
README.md Updates documentation and usage instructions for Python integration
Comments suppressed due to low confidence (1)

src/prime_cli/init.py:20

  • The set_api_key function updates the configuration but does not refresh the APIClient, which is instantiated before the API key is set. Verify that APIClient properly picks up the updated credentials or consider re-instantiating it after changing the API key.
def set_api_key(api_key: str) -> None:


def create_pod(pod_config: PodConfig) -> Pod:
"""Create a new pod"""
return pods_client.create(pod_config.__dict__)
Copy link
Preview

Copilot AI May 5, 2025

Choose a reason for hiding this comment

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

[nitpick] Using pod_config.dict directly might bypass validations or transformations provided by PodConfig. Consider using an explicit serialization method to ensure data integrity.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant