Skip to content

Add lease client to fake spot#29

Merged
arkinj merged 2 commits intomainfrom
feature/fake_spot_lease_manager
Oct 7, 2025
Merged

Add lease client to fake spot#29
arkinj merged 2 commits intomainfrom
feature/fake_spot_lease_manager

Conversation

@y-veys
Copy link
Collaborator

@y-veys y-veys commented Oct 3, 2025

No description provided.

@y-veys y-veys requested review from GoldenZephyr and Copilot October 3, 2025 15:29
Copy link

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

Add a minimal fake lease client and wire it into FakeSpot to support lease-aware workflows in tests and simulations.

  • Introduces LeaseOwner and Lease dataclasses
  • Adds FakeLeaseClient with list_leases()
  • Wires lease_client into FakeSpot initialization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

def list_leases(self):
lease_owner = LeaseOwner("fake_spot_lease_owner")
lease = [Lease(lease_owner)]
return [lease]
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

list_leases() currently returns a nested list (List[List[Lease]]) due to wrapping the already-list 'lease' in another list. Return a flat list instead, e.g., either 'return lease' or construct and return a single list in one step.

Suggested change
return [lease]
return lease

Copilot uses AI. Check for mistakes.
@y-veys y-veys requested a review from Copilot October 3, 2025 15:46
Copy link

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 1 out of 1 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +175 to +182
class FakeLeaseClient:
def __init__(self, fake_spot):
self.fake_spot = fake_spot

def list_leases(self):
lease_owner = LeaseOwner("fake_spot_lease_owner")
lease = [Lease(lease_owner)]
return lease
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

[nitpick] list_leases returns a bare list of Lease objects, which diverges from the typical Spot LeaseClient API that returns a response object with a resources collection. To make this fake a drop-in replacement for callers expecting the real client, return an object with a resources attribute (e.g., a simple dataclass wrapper like ListLeasesResponse with resources: list[LeaseResource]) or match whatever structure your production code consumes.

Copilot uses AI. Check for mistakes.
Comment on lines +165 to +170
@dataclass
class LeaseOwner:
client_name: str


@dataclass
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider making these dataclasses immutable to prevent accidental mutation of lease metadata in tests: use @DataClass(frozen=True). Immutability better reflects how lease metadata is typically treated and avoids hard-to-track side effects.

Suggested change
@dataclass
class LeaseOwner:
client_name: str
@dataclass
@dataclass(frozen=True)
class LeaseOwner:
client_name: str
@dataclass(frozen=True)

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@GoldenZephyr GoldenZephyr left a comment

Choose a reason for hiding this comment

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

Looks good!

@arkinj arkinj merged commit f1cf793 into main Oct 7, 2025
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.

3 participants