Skip to content

Feature/add instance type images query#93

Open
tamirse wants to merge 3 commits intomasterfrom
feature/add-instance-type-images-query
Open

Feature/add instance type images query#93
tamirse wants to merge 3 commits intomasterfrom
feature/add-instance-type-images-query

Conversation

@tamirse
Copy link
Copy Markdown
Collaborator

@tamirse tamirse commented Mar 31, 2026

Added

  • Support for querying OS images by instance type via verda.images.get(instance_type=...)

Changed

  • Refactored Image model to use @dataclass and @dataclass_json for consistency with Instance and Volume

Copy link
Copy Markdown
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

Adds support for filtering OS images by instance type via ImagesService.get(instance_type=...) and refactors the Image model to a dataclass using dataclasses_json for (de)serialization consistency.

Changes:

  • Refactor verda.images.Image to @dataclass + @dataclass_json and switch parsing to Image.from_dict(...).
  • Add optional instance_type query parameter to ImagesService.get() and corresponding unit test.
  • Document the feature and refactor in CHANGELOG.md.

Reviewed changes

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

File Description
verda/images/_images.py Converts Image to a dataclass/json model and adds instance_type filtering to the images list call.
tests/unit_tests/images/test_images.py Refactors existing test payload reuse and adds a test asserting the instance_type query param is sent.
CHANGELOG.md Notes the new query capability and the Image dataclass refactor under Unreleased.

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

Comment on lines +8 to 12
@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclass
class Image:
"""An image model class."""

def __init__(self, id: str, name: str, image_type: str, details: list[str]) -> None:
"""Initialize an image object.

:param id: image id
:type id: str
:param name: image name
:type name: str
:param image_type: image type, e.g. 'ubuntu-20.04-cuda-11.0'
:type image_type: str
:param details: image details
:type details: list[str]
"""
self._id = id
self._name = name
self._image_type = image_type
self._details = details

@property
def id(self) -> str:
"""Get the image id.

:return: image id
:rtype: str
"""
return self._id

@property
def name(self) -> str:
"""Get the image name.

:return: image name
:rtype: str
"""
return self._name

@property
def image_type(self) -> str:
"""Get the image type.
"""Represents an OS image available for instances.

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The refactor removes Image.str() (previously returned a JSON-formatted string). If any SDK consumers relied on str(image) producing JSON (e.g., for logging/serialization), this is a backward-incompatible behavior change. Consider restoring a JSON-oriented str (e.g., delegating to dataclasses_json's serialization) or explicitly calling out this behavior change in the changelog/migration notes.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Copy link
Copy Markdown
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 3 out of 3 changed files in this pull request and generated 1 comment.


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

for image in images
]
return image_objects
params = {'instance_type': instance_type} if instance_type else None
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

params = {'instance_type': instance_type} if instance_type else None treats empty strings as “no filter”. If a caller passes instance_type='' (or any other falsy-but-valid string), the SDK will silently omit the query param. Prefer checking instance_type is not None (or always passing {'instance_type': instance_type} and letting requests drop None values) so only None means “no filter.”

Suggested change
params = {'instance_type': instance_type} if instance_type else None
params = {'instance_type': instance_type} if instance_type is not None else None

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants