Skip to content

Refactor Client API#150

Merged
adambalogh merged 14 commits intomainfrom
aba/client
Feb 6, 2026
Merged

Refactor Client API#150
adambalogh merged 14 commits intomainfrom
aba/client

Conversation

@adambalogh
Copy link
Collaborator

@adambalogh adambalogh commented Feb 5, 2026

This PR refactors the Client API by splitting the monolithic client.py file into smaller, modular namespace-based components. The refactoring introduces separate modules for LLM operations (llm.py), onchain inference (onchain_inference.py), model hub functionality (model_hub.py), and alpha features (alpha.py). The new structure provides cleaner separation of concerns and improved code organization.

@adambalogh adambalogh requested a review from Copilot February 6, 2026 10:19
Copy link
Contributor

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 the Client API by splitting the monolithic client.py file into smaller, modular namespace-based components. The refactoring introduces separate modules for LLM operations (llm.py), onchain inference (onchain_inference.py), model hub functionality (model_hub.py), and alpha features (alpha.py). The new structure provides cleaner separation of concerns and improved code organization.

Changes:

  • Split monolithic client.py into modular namespace components (LLM, Inference, ModelHub, Alpha)
  • Updated all client method calls to use namespace accessors (e.g., client.llm.chat(), client.inference.infer())
  • Reorganized imports and moved utility functions to dedicated modules (_utils.py, _conversions.py)

Reviewed changes

Copilot reviewed 38 out of 40 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/opengradient/client/client.py New modular client implementation with namespace properties
src/opengradient/client/llm.py Extracted LLM-specific functionality into dedicated namespace
src/opengradient/client/onchain_inference.py Extracted onchain inference functionality into dedicated namespace
src/opengradient/client/model_hub.py Extracted Model Hub functionality into dedicated namespace
src/opengradient/client/alpha.py Moved Alpha features to client submodule
src/opengradient/client/_utils.py Utility functions for ABI/bytecode loading and retry logic
src/opengradient/client/_conversions.py Data conversion utilities moved from main client
tests/client_test.py Updated tests to use new namespace accessors
examples/*.py Updated example code to use new client API structure
src/opengradient/workflow_models/*.py Updated to accept Alpha namespace as parameter
src/opengradient/alphasense/*.py Updated tools to accept namespace instances as parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +86 to +88
print(f"Gas estimation failed: {str(e)}")
gas_limit = 5000000 # Conservative fallback
print(f"Using fallback gas limit: {gas_limit}")
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Using print() statements for error reporting is not consistent with production-quality error handling. Consider using Python's logging module instead (e.g., logging.warning()) to provide configurable and structured error reporting that can be controlled by the application using this SDK.

Copilot uses AI. Check for mistakes.
balogh.adam@icloud.com and others added 7 commits February 6, 2026 11:31
@adambalogh adambalogh requested a review from Copilot February 6, 2026 10:59
Copy link
Contributor

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

Copilot reviewed 51 out of 54 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# dobj.module is None so pull module name from qualname
parts = dobj.qualname.split('.')
if len(parts) < 2:
return '`{}`'.format(parts[0])
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

Inconsistent indentation: the added lines use 2 spaces while the surrounding code uses 4 spaces. This should match the file's indentation style.

Suggested change
return '`{}`'.format(parts[0])
return '`{}`'.format(parts[0])

Copilot uses AI. Check for mistakes.


def read_sui_1_hour_price_forecast() -> WorkflowModelOutput:
def read_sui_1_hour_price_forecast(alpha: Alpha) -> WorkflowModelOutput:
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The function signature changed to require an alpha parameter, but the docstring doesn't document this new parameter. Add an Args section documenting the alpha parameter.

Copilot uses AI. Check for mistakes.


def read_sui_usdt_30_min_price_forecast() -> WorkflowModelOutput:
def read_sui_usdt_30_min_price_forecast(alpha: Alpha) -> WorkflowModelOutput:
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The function signature changed to require an alpha parameter, but the docstring doesn't document this new parameter. Add an Args section documenting the alpha parameter.

Copilot uses AI. Check for mistakes.
@adambalogh adambalogh merged commit 7a88335 into main Feb 6, 2026
2 checks passed
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