Skip to content

Commit

Permalink
move base classes to __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgorana committed Dec 15, 2024
1 parent 8432263 commit 0381d61
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
30 changes: 1 addition & 29 deletions syftbox/client/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING

import httpx
from loguru import logger
Expand Down Expand Up @@ -114,30 +113,3 @@ def from_config(cls, config: SyftClientConfig):
headers=cls._make_headers(config),
)
return cls(conn)


@dataclass
class BaseMetric:
"""Base class for all metrics with common fields."""

num_runs: int


class MetricCollector(Protocol):
"""
Protocol for classes that collect performance metrics.
"""

client_config: SyftClientConfig

def collect_metrics(self, num_runs: int) -> BaseMetric:
"""Calculate performance metrics."""
...


class BenchmarkReporter(Protocol):
"""Protocol defining the interface for benchmark result reporters."""

def generate(self, metrics: dict[str, BaseMetric], report_path: Optional[Path] = None) -> Any:
"""Generate the benchmark report."""
...
34 changes: 34 additions & 0 deletions syftbox/client/benchmark/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any, Optional

from typing_extensions import Protocol

from syftbox.lib.client_config import SyftClientConfig


@dataclass
class BaseMetric:
"""Base class for all metrics with common fields."""

num_runs: int


class MetricCollector(Protocol):
"""
Protocol for classes that collect performance metrics.
"""

client_config: SyftClientConfig

def collect_metrics(self, num_runs: int) -> BaseMetric:
"""Calculate performance metrics."""
...


class BenchmarkReporter(Protocol):
"""Protocol defining the interface for benchmark result reporters."""

def generate(self, metrics: dict[str, BaseMetric], report_path: Optional[Path] = None) -> Any:
"""Generate the benchmark report."""
...

0 comments on commit 0381d61

Please sign in to comment.