Skip to content

Add BaseDeviceConnector and DeviceConnectorProtocol for standardized device connector patterns#3

Draft
Copilot wants to merge 6 commits intocopilot-hackathonfrom
copilot/vscode1762196374538
Draft

Add BaseDeviceConnector and DeviceConnectorProtocol for standardized device connector patterns#3
Copilot wants to merge 6 commits intocopilot-hackathonfrom
copilot/vscode1762196374538

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 3, 2025

Phase 1 of device connector refactoring (#2). Adds foundation classes for standardizing configuration loading, logging, error handling, and serial logger management across 16+ device connectors without breaking existing implementations.

Changes

New Base Classes

  • DeviceConnectorProtocol: Runtime-checkable Protocol (PEP 544) defining the device connector interface for type checking
  • BaseDeviceConnector: Base class providing:
    • load_config(path) / load_job_data(path) - Standardized YAML/JSON loading
    • run_phase(name, func, *args, **kwargs) - Consistent BEGIN/END logging and error handling
    • create_serial_logger(config, filename) - Unified serial logger lifecycle
    • get_provision_data() / get_test_data() / get_test_username() - Safe data extraction

Usage Pattern

from testflinger_device_connectors.devices import DefaultDevice
from testflinger_device_connectors.devices.base import BaseDeviceConnector

class DeviceConnector(BaseDeviceConnector, DefaultDevice):
    def provision(self, args):
        config = self.load_config(args.config)
        job_data = self.load_job_data(args.job_data)
        return self.run_phase("provision", self._do_provision, config, job_data)
    
    def _do_provision(self, config, job_data):
        image_url = self.get_provision_data(job_data, "image_url")
        # provisioning logic
        return 0

Documentation

  • docs/NEW_BASE_CLASSES.md - API reference, usage patterns, migration guide
  • docs/EXAMPLES.md - Three implementation patterns with error handling examples

Testing

  • 30 new tests covering protocol validation, config/data loading, phase execution, error handling, and helper methods
  • All 139 tests passing (109 existing + 30 new)

Design

Non-breaking: Existing DefaultDevice unchanged, all current connectors work without modification. New classes are additive and optional, enabling incremental adoption in future phases.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

can you please take a look at #2 issue and take care of the first item: Phase 1: Add New Base Classes (Non-Breaking)

Created from VS Code via the GitHub Pull Request extension.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits November 3, 2025 11:04
Co-authored-by: rene-oromtz <157750458+rene-oromtz@users.noreply.github.com>
…e tests and documentation

Co-authored-by: rene-oromtz <157750458+rene-oromtz@users.noreply.github.com>
Co-authored-by: rene-oromtz <157750458+rene-oromtz@users.noreply.github.com>
Co-authored-by: rene-oromtz <157750458+rene-oromtz@users.noreply.github.com>
Copilot AI changed the title [WIP] can you please take ... Add BaseDeviceConnector and DeviceConnectorProtocol for standardized device connector patterns Nov 3, 2025
Copilot AI requested a review from rene-oromtz November 3, 2025 11:18
rene-oromtz and others added 2 commits November 3, 2025 11:59
Co-authored-by: rene-oromtz <157750458+rene-oromtz@users.noreply.github.com>
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