Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kagglesdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.38"
__version__ = "0.1.39"

from kagglesdk.kaggle_client import KaggleClient
from kagglesdk.kaggle_creds import KaggleCredentials
Expand Down
32 changes: 31 additions & 1 deletion kagglesdk/benchmarks/services/benchmark_tasks_api_service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from kagglesdk.benchmarks.types.benchmark_task_run_service import GetBenchmarkSchedulerStatusResponse
from kagglesdk.benchmarks.types.benchmark_tasks_api_service import ApiBatchScheduleBenchmarkTaskRunsRequest, ApiBatchScheduleBenchmarkTaskRunsResponse, ApiBenchmarkTask, ApiCancelBenchmarkTaskRunsRequest, ApiCancelBenchmarkTaskRunsResponse, ApiCreateBenchmarkTaskRequest, ApiDownloadBenchmarkTaskRunOutputRequest, ApiGetBenchmarkSchedulerStatusRequest, ApiGetBenchmarkTaskQuotaRequest, ApiGetBenchmarkTaskQuotaResponse, ApiGetBenchmarkTaskRequest, ApiGetBenchmarkTaskRunLogsRequest, ApiListBenchmarkTaskRunsRequest, ApiListBenchmarkTaskRunsResponse, ApiListBenchmarkTasksRequest, ApiListBenchmarkTasksResponse, ApiPublishBenchmarkTaskRequest, ApiUpdateBenchmarkTaskRequest, ApiUpdateBenchmarkTaskResponse, ApiUpdateBenchmarkTaskVersionRequest
from kagglesdk.benchmarks.types.benchmark_tasks_api_service import ApiBatchScheduleBenchmarkTaskRunsRequest, ApiBatchScheduleBenchmarkTaskRunsResponse, ApiBenchmarkTask, ApiBenchmarkTaskCollaborators, ApiCancelBenchmarkTaskRunsRequest, ApiCancelBenchmarkTaskRunsResponse, ApiCreateBenchmarkTaskRequest, ApiDownloadBenchmarkTaskRunOutputRequest, ApiGetBenchmarkSchedulerStatusRequest, ApiGetBenchmarkTaskCollaboratorsRequest, ApiGetBenchmarkTaskQuotaRequest, ApiGetBenchmarkTaskQuotaResponse, ApiGetBenchmarkTaskRequest, ApiGetBenchmarkTaskRunLogsRequest, ApiListBenchmarkTaskRunsRequest, ApiListBenchmarkTaskRunsResponse, ApiListBenchmarkTasksRequest, ApiListBenchmarkTasksResponse, ApiPublishBenchmarkTaskRequest, ApiUpdateBenchmarkTaskCollaboratorsRequest, ApiUpdateBenchmarkTaskRequest, ApiUpdateBenchmarkTaskResponse, ApiUpdateBenchmarkTaskVersionRequest
from kagglesdk.common.types.file_download import FileDownload
from kagglesdk.kaggle_http_client import KaggleHttpClient

Expand Down Expand Up @@ -208,3 +208,33 @@ def update_benchmark_task_version(self, request: ApiUpdateBenchmarkTaskVersionRe
request = ApiUpdateBenchmarkTaskVersionRequest()

return self._client.call("benchmarks.BenchmarkTasksApiService", "UpdateBenchmarkTaskVersion", request, ApiBenchmarkTask)

def get_benchmark_task_collaborators(self, request: ApiGetBenchmarkTaskCollaboratorsRequest = None) -> ApiBenchmarkTaskCollaborators:
r"""
List the users and groups who collaborate on a task and the role each one
holds. The owner isn't included.

Args:
request (ApiGetBenchmarkTaskCollaboratorsRequest):
The request object; initialized to empty instance if not specified.
"""

if request is None:
request = ApiGetBenchmarkTaskCollaboratorsRequest()

return self._client.call("benchmarks.BenchmarkTasksApiService", "GetBenchmarkTaskCollaborators", request, ApiBenchmarkTaskCollaborators)

def update_benchmark_task_collaborators(self, request: ApiUpdateBenchmarkTaskCollaboratorsRequest = None) -> ApiBenchmarkTaskCollaborators:
r"""
Add, re-role or remove collaborators on a task. Collaborators the request
doesn't name are left as they are.

Args:
request (ApiUpdateBenchmarkTaskCollaboratorsRequest):
The request object; initialized to empty instance if not specified.
"""

if request is None:
request = ApiUpdateBenchmarkTaskCollaboratorsRequest()

return self._client.call("benchmarks.BenchmarkTasksApiService", "UpdateBenchmarkTaskCollaborators", request, ApiBenchmarkTaskCollaborators)
89 changes: 84 additions & 5 deletions kagglesdk/benchmarks/services/benchmarks_api_service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from kagglesdk.benchmarks.types.benchmark_types import BenchmarkArenaSettings
from kagglesdk.benchmarks.types.benchmarks_api_service import ApiAddTasksToBenchmarkRequest, ApiAddTasksToBenchmarkResponse, ApiBenchmarkLeaderboard, ApiBenchmarkModelVersionConfig, ApiCreateBenchmarkArenaSettingsRequest, ApiCreateBenchmarkModelVersionConfigRequest, ApiCreateBenchmarkVersionAgentMappingsRequest, ApiCreateBenchmarkVersionAgentMappingsResponse, ApiDeleteBenchmarkVersionAgentMappingsRequest, ApiDeleteBenchmarkVersionAgentMappingsResponse, ApiGetBenchmarkArenaSettingsRequest, ApiGetBenchmarkLeaderboardRequest, ApiGetBenchmarkModelVersionConfigRequest, ApiListBenchmarkArenaCombinationsRequest, ApiListBenchmarkArenaCombinationsResponse, ApiListBenchmarkModelsRequest, ApiListBenchmarkModelsResponse, ApiListBenchmarkModelVersionConfigsRequest, ApiListBenchmarkModelVersionConfigsResponse, ApiListBenchmarkVersionAgentMappingsRequest, ApiListBenchmarkVersionAgentMappingsResponse, ApiRegisterAuxiliaryModelVersionConfigsRequest, ApiRemoveTasksFromBenchmarkRequest, ApiRemoveTasksFromBenchmarkResponse, ApiUnregisterAuxiliaryModelVersionConfigsRequest, ApiUpdateBenchmarkArenaCombinationsRequest, ApiUpdateBenchmarkArenaSettingsRequest
from kagglesdk.benchmarks.types.benchmark_types import BenchmarkArenaSettings, BenchmarkMetricProducer
from kagglesdk.benchmarks.types.benchmarks_api_service import ApiAddTasksToBenchmarkRequest, ApiAddTasksToBenchmarkResponse, ApiBatchScheduleBenchmarkMetricsRequest, ApiBatchScheduleBenchmarkMetricsResponse, ApiBenchmarkLeaderboard, ApiBenchmarkModelVersionConfig, ApiCreateBenchmarkArenaSettingsRequest, ApiCreateBenchmarkMetricProducerRequest, ApiCreateBenchmarkModelVersionConfigRequest, ApiCreateBenchmarkVersionAgentMappingsRequest, ApiCreateBenchmarkVersionAgentMappingsResponse, ApiDeleteBenchmarkVersionAgentMappingsRequest, ApiDeleteBenchmarkVersionAgentMappingsResponse, ApiGetBenchmarkArenaSettingsRequest, ApiGetBenchmarkLeaderboardRequest, ApiGetBenchmarkModelVersionConfigRequest, ApiListBenchmarkArenaCombinationsRequest, ApiListBenchmarkArenaCombinationsResponse, ApiListBenchmarkModelsRequest, ApiListBenchmarkModelsResponse, ApiListBenchmarkModelVersionConfigsRequest, ApiListBenchmarkModelVersionConfigsResponse, ApiListBenchmarkVersionAgentMappingsRequest, ApiListBenchmarkVersionAgentMappingsResponse, ApiRegisterAuxiliaryModelVersionConfigsRequest, ApiRemoveTasksFromBenchmarkRequest, ApiRemoveTasksFromBenchmarkResponse, ApiUnregisterAuxiliaryModelVersionConfigsRequest, ApiUpdateBenchmarkArenaCombinationsRequest, ApiUpdateBenchmarkArenaCombinationsResponse, ApiUpdateBenchmarkArenaSettingsRequest, ApiValidateBenchmarkMetricProducerOutputRequest, ApiValidateBenchmarkMetricProducerOutputResponse
from kagglesdk.kaggle_http_client import KaggleHttpClient

class BenchmarksApiClient(object):
Expand Down Expand Up @@ -376,11 +376,12 @@ def list_benchmark_arena_combinations(self, request: ApiListBenchmarkArenaCombin

return self._client.call("benchmarks.BenchmarksApiService", "ListBenchmarkArenaCombinations", request, ApiListBenchmarkArenaCombinationsResponse)

def update_benchmark_arena_combinations(self, request: ApiUpdateBenchmarkArenaCombinationsRequest = None):
def update_benchmark_arena_combinations(self, request: ApiUpdateBenchmarkArenaCombinationsRequest = None) -> ApiUpdateBenchmarkArenaCombinationsResponse:
r"""
Opt (task version, candidate) combinations into or out of a benchmark
version's arena. Requires update access to the benchmark version and read
access to each candidate added.
access to each candidate added. Added combinations with nothing to show
voters are skipped and returned; the rest are saved.

Example:
curl -sSL -u fickleone:local_api_token \
Expand All @@ -402,4 +403,82 @@ def update_benchmark_arena_combinations(self, request: ApiUpdateBenchmarkArenaCo
if request is None:
request = ApiUpdateBenchmarkArenaCombinationsRequest()

self._client.call("benchmarks.BenchmarksApiService", "UpdateBenchmarkArenaCombinations", request, None)
return self._client.call("benchmarks.BenchmarksApiService", "UpdateBenchmarkArenaCombinations", request, ApiUpdateBenchmarkArenaCombinationsResponse)

def create_benchmark_metric_producer(self, request: ApiCreateBenchmarkMetricProducerRequest = None) -> BenchmarkMetricProducer:
r"""
Create a BenchmarkMetricProducer on a benchmark version. Requires update
access to the benchmark version and read access to the definition and
mounted datasets.

Example:
curl -sSL -u fickleone:local_api_token \
-X POST \
http://localhost/api/v1/benchmarks/fickleone/my-benchmark/metric-producers/create
\
-H 'Content-Type: application/json' \
-d '{
'definitionSource': {
'datasetVersionSlug': 'fickleone/my-metrics/versions/1'
},
'entrypoint': 'main.py',
'inputOptions': {'resultsOnly': true}
}'

Args:
request (ApiCreateBenchmarkMetricProducerRequest):
The request object; initialized to empty instance if not specified.
"""

if request is None:
request = ApiCreateBenchmarkMetricProducerRequest()

return self._client.call("benchmarks.BenchmarksApiService", "CreateBenchmarkMetricProducer", request, BenchmarkMetricProducer)

def batch_schedule_benchmark_metrics(self, request: ApiBatchScheduleBenchmarkMetricsRequest = None) -> ApiBatchScheduleBenchmarkMetricsResponse:
r"""
Run one of a benchmark version's metric producers: stages the version's
latest completed runs, then starts the producer's session. Requires update
access to the benchmark version.

Example:
curl -sSL -u fickleone:local_api_token \
-X POST \
http://localhost/api/v1/benchmarks/fickleone/my-benchmark/metrics/schedule
\
-H 'Content-Type: application/json' \
-d '{'benchmarkMetricProducerId': 1}'

Args:
request (ApiBatchScheduleBenchmarkMetricsRequest):
The request object; initialized to empty instance if not specified.
"""

if request is None:
request = ApiBatchScheduleBenchmarkMetricsRequest()

return self._client.call("benchmarks.BenchmarksApiService", "BatchScheduleBenchmarkMetrics", request, ApiBatchScheduleBenchmarkMetricsResponse)

def validate_benchmark_metric_producer_output(self, request: ApiValidateBenchmarkMetricProducerOutputRequest = None) -> ApiValidateBenchmarkMetricProducerOutputResponse:
r"""
Validate a BenchmarkMetricProducerOutput JSON payload against a benchmark
version's mapped candidates and manual metrics without persisting anything.
Requires update access to the benchmark version.

Example:
curl -sSL -u fickleone:local_api_token \
-X POST \
http://localhost/api/v1/benchmarks/fickleone/my-benchmark/metric-producers/validate-output
\
-H 'Content-Type: application/json' \
-d '{'outputJson': '{\'version\':1,\'metrics\':[...]}'}'

Args:
request (ApiValidateBenchmarkMetricProducerOutputRequest):
The request object; initialized to empty instance if not specified.
"""

if request is None:
request = ApiValidateBenchmarkMetricProducerOutputRequest()

return self._client.call("benchmarks.BenchmarksApiService", "ValidateBenchmarkMetricProducerOutput", request, ApiValidateBenchmarkMetricProducerOutputResponse)
10 changes: 10 additions & 0 deletions kagglesdk/benchmarks/types/benchmark_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ class BenchmarkLeaderboardDisplayType(enum.Enum):
$2,601,845, $456, $790
"""

class BenchmarkTaskCollaboratorRole(enum.Enum):
"""What a task collaborator can do. Each role includes the ones above it."""
BENCHMARK_TASK_COLLABORATOR_ROLE_UNSPECIFIED = 0
BENCHMARK_TASK_COLLABORATOR_ROLE_VIEWER = 1
"""Can view the task while it's private."""
BENCHMARK_TASK_COLLABORATOR_ROLE_EDITOR = 2
"""Can also edit the task."""
BENCHMARK_TASK_COLLABORATOR_ROLE_ADMIN = 3
"""Can also change the task's visibility and collaborators."""

class BenchmarkTaskRunState(enum.Enum):
BENCHMARK_TASK_RUN_STATE_UNSPECIFIED = 0
BENCHMARK_TASK_RUN_STATE_QUEUED = 1
Expand Down
6 changes: 4 additions & 2 deletions kagglesdk/benchmarks/types/benchmark_task_run_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ class GetBenchmarkSchedulerStatusResponse(KaggleObject):
Excludes cancellations, which are stamped Errored and removed.
model_version_stats (BenchmarkSchedulerModelVersionStats)
One entry per model version with live work or a recent outcome, ordered
by running count descending, then id ascending so ties stay stable.
by queued count descending, then running count descending, then id
ascending so ties stay stable.
settings (BenchmarkSchedulerSettings)
The settings these counts were measured against. The caps are enforced over
the enqueued-only population, so headroom is their difference from the
Expand Down Expand Up @@ -515,7 +516,8 @@ def recent_state_counts(self, recent_state_counts: Optional[List[Optional['Bench
def model_version_stats(self) -> Optional[List[Optional['BenchmarkSchedulerModelVersionStats']]]:
r"""
One entry per model version with live work or a recent outcome, ordered
by running count descending, then id ascending so ties stay stable.
by queued count descending, then running count descending, then id
ascending so ties stay stable.
"""
return self._model_version_stats

Expand Down
Loading