Skip to content
Merged
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.37"
__version__ = "0.1.38"

from kagglesdk.kaggle_client import KaggleClient
from kagglesdk.kaggle_creds import KaggleCredentials
Expand Down
34 changes: 33 additions & 1 deletion kagglesdk/benchmarks/services/benchmark_tasks_api_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from kagglesdk.benchmarks.types.benchmark_tasks_api_service import ApiBatchScheduleBenchmarkTaskRunsRequest, ApiBatchScheduleBenchmarkTaskRunsResponse, ApiBenchmarkTask, ApiCreateBenchmarkTaskRequest, ApiDownloadBenchmarkTaskRunOutputRequest, ApiGetBenchmarkTaskQuotaRequest, ApiGetBenchmarkTaskQuotaResponse, ApiGetBenchmarkTaskRequest, ApiGetBenchmarkTaskRunLogsRequest, ApiListBenchmarkTaskRunsRequest, ApiListBenchmarkTaskRunsResponse, ApiListBenchmarkTasksRequest, ApiListBenchmarkTasksResponse, ApiPublishBenchmarkTaskRequest
from kagglesdk.benchmarks.types.benchmark_tasks_api_service import ApiBatchScheduleBenchmarkTaskRunsRequest, ApiBatchScheduleBenchmarkTaskRunsResponse, ApiBenchmarkTask, ApiCreateBenchmarkTaskRequest, ApiDownloadBenchmarkTaskRunOutputRequest, ApiGetBenchmarkTaskQuotaRequest, ApiGetBenchmarkTaskQuotaResponse, ApiGetBenchmarkTaskRequest, ApiGetBenchmarkTaskRunLogsRequest, ApiListBenchmarkTaskRunsRequest, ApiListBenchmarkTaskRunsResponse, ApiListBenchmarkTasksRequest, ApiListBenchmarkTasksResponse, ApiPublishBenchmarkTaskRequest, ApiUpdateBenchmarkTaskRequest, ApiUpdateBenchmarkTaskResponse, ApiUpdateBenchmarkTaskVersionRequest
from kagglesdk.common.types.file_download import FileDownload
from kagglesdk.kaggle_http_client import KaggleHttpClient

Expand Down Expand Up @@ -141,3 +141,35 @@ def publish_benchmark_task(self, request: ApiPublishBenchmarkTaskRequest = None)
request = ApiPublishBenchmarkTaskRequest()

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

def update_benchmark_task(self, request: ApiUpdateBenchmarkTaskRequest = None) -> ApiUpdateBenchmarkTaskResponse:
r"""
Update editable metadata (description, tags, provenance, citations) on a
task. Only the fields named in `update_mask` are written. Everything but
`tags` is written to the task's *current* version; to target an older
version, use UpdateBenchmarkTaskVersion.

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

if request is None:
request = ApiUpdateBenchmarkTaskRequest()

return self._client.call("benchmarks.BenchmarkTasksApiService", "UpdateBenchmarkTask", request, ApiUpdateBenchmarkTaskResponse)

def update_benchmark_task_version(self, request: ApiUpdateBenchmarkTaskVersionRequest = None) -> ApiBenchmarkTask:
r"""
Update editable metadata on one specific version of a task. Unlike
UpdateBenchmarkTask, the version named by the slug is the version written.

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

if request is None:
request = ApiUpdateBenchmarkTaskVersionRequest()

return self._client.call("benchmarks.BenchmarkTasksApiService", "UpdateBenchmarkTaskVersion", request, ApiBenchmarkTask)
34 changes: 33 additions & 1 deletion kagglesdk/benchmarks/services/benchmarks_api_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from kagglesdk.benchmarks.types.benchmarks_api_service import ApiBenchmarkLeaderboard, ApiBenchmarkModelVersionConfig, ApiCreateBenchmarkModelVersionConfigRequest, ApiCreateBenchmarkVersionAgentMappingsRequest, ApiCreateBenchmarkVersionAgentMappingsResponse, ApiDeleteBenchmarkVersionAgentMappingsRequest, ApiDeleteBenchmarkVersionAgentMappingsResponse, ApiGetBenchmarkLeaderboardRequest, ApiGetBenchmarkModelVersionConfigRequest, ApiListBenchmarkModelsRequest, ApiListBenchmarkModelsResponse, ApiListBenchmarkModelVersionConfigsRequest, ApiListBenchmarkModelVersionConfigsResponse, ApiListBenchmarkVersionAgentMappingsRequest, ApiListBenchmarkVersionAgentMappingsResponse
from kagglesdk.benchmarks.types.benchmarks_api_service import ApiAddTasksToBenchmarkRequest, ApiAddTasksToBenchmarkResponse, ApiBenchmarkLeaderboard, ApiBenchmarkModelVersionConfig, ApiCreateBenchmarkModelVersionConfigRequest, ApiCreateBenchmarkVersionAgentMappingsRequest, ApiCreateBenchmarkVersionAgentMappingsResponse, ApiDeleteBenchmarkVersionAgentMappingsRequest, ApiDeleteBenchmarkVersionAgentMappingsResponse, ApiGetBenchmarkLeaderboardRequest, ApiGetBenchmarkModelVersionConfigRequest, ApiListBenchmarkModelsRequest, ApiListBenchmarkModelsResponse, ApiListBenchmarkModelVersionConfigsRequest, ApiListBenchmarkModelVersionConfigsResponse, ApiListBenchmarkVersionAgentMappingsRequest, ApiListBenchmarkVersionAgentMappingsResponse
from kagglesdk.kaggle_http_client import KaggleHttpClient

class BenchmarksApiClient(object):
Expand Down Expand Up @@ -184,3 +184,35 @@ def list_benchmark_version_agent_mappings(self, request: ApiListBenchmarkVersion
request = ApiListBenchmarkVersionAgentMappingsRequest()

return self._client.call("benchmarks.BenchmarksApiService", "ListBenchmarkVersionAgentMappings", request, ApiListBenchmarkVersionAgentMappingsResponse)

def add_tasks_to_benchmark(self, request: ApiAddTasksToBenchmarkRequest = None) -> ApiAddTasksToBenchmarkResponse:
r"""
Map one or more BenchmarkTasks into one of the current user's own
benchmarks, making them part of that benchmark's task tree and
leaderboard. Only supported for benchmarks of type Personal. Requires
update access to the benchmark version and read access to each task. Tasks
already mapped to the benchmark are skipped and echoed back in
`skipped_tasks` rather than failing the request, so a partially-applied
bulk import can be safely re-run.

Example:
curl -sSL -u fickleone:local_api_token \
-X POST \
http://localhost/api/v1/benchmarks/my-benchmark/tasks/add \
-H 'Content-Type: application/json' \
-d '{
'taskSlugs': [
{'taskSlug': 'count-letters'},
{'ownerSlug': 'bob', 'taskSlug': 'sort-list', 'versionNumber': 2}
]
}'

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

if request is None:
request = ApiAddTasksToBenchmarkRequest()

return self._client.call("benchmarks.BenchmarksApiService", "AddTasksToBenchmark", request, ApiAddTasksToBenchmarkResponse)
9 changes: 9 additions & 0 deletions kagglesdk/benchmarks/types/benchmark_enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import enum

class BenchmarkCandidateType(enum.Enum):
r"""
Saved to the DB. Do not modify existing values.
The kind of candidate a BenchmarkTaskVersion evaluates.
"""
BENCHMARK_CANDIDATE_TYPE_UNSPECIFIED = 0
BENCHMARK_CANDIDATE_TYPE_MODEL_VERSIONS = 1
BENCHMARK_CANDIDATE_TYPE_AGENTS = 2

class BenchmarkModelImportanceLevel(enum.Enum):
r"""
Determines whether the model will be run on
Expand Down
65 changes: 53 additions & 12 deletions kagglesdk/benchmarks/types/benchmark_task_run_service.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from kagglesdk.benchmarks.types.benchmark_enums import BenchmarkCandidateType
from kagglesdk.kaggle_object import *
from typing import Optional

Expand All @@ -6,20 +7,25 @@ class BatchScheduleBenchmarkModelVersionResult(KaggleObject):
Attributes:
benchmark_model_version_id (int)
One of the values provided in
BatchScheduleBenchmarkTaskRunsRequest.benchmark_model_versions
BatchScheduleBenchmarkTaskRunsRequest.benchmark_model_version_ids
run_scheduled (bool)
Whether the run was scheduled for the provided (benchmark_task_version,
benchmark_model_version) pair
Whether the run was scheduled for the provided (TaskVersion, Candidate)
pair.
run_skipped_reason (str)
If run_scheduled was false, the reason the provided
(benchmark_task_version, benchmark_model_version) pair was skipped
If run_scheduled was false, the reason the (TaskVersion, Candidate) pair
was skipped
benchmark_task_version_id (int)
One of the values provided in
BatchScheduleBenchmarkTaskRunsRequest.benchmark_task_versions
BatchScheduleBenchmarkTaskRunsRequest.benchmark_task_version_ids
parent_task_version_id (int)
When the requested benchmark_task_version_id is a child of another task
version, scheduling is redirected to the parent and this field reports the
parent's id. Unset when the requested task version was executed directly.
agent_id (int)
One of the values provided in
BatchScheduleBenchmarkTaskRunsRequest.benchmark_agent_ids
candidate_type (BenchmarkCandidateType)
Specifies the candidate type that was scheduled (ModelVersion vs. Agent)
"""

def __init__(self):
Expand All @@ -28,13 +34,15 @@ def __init__(self):
self._run_skipped_reason = None
self._benchmark_task_version_id = 0
self._parent_task_version_id = None
self._agent_id = 0
self._candidate_type = BenchmarkCandidateType.BENCHMARK_CANDIDATE_TYPE_UNSPECIFIED
self._freeze()

@property
def benchmark_task_version_id(self) -> int:
r"""
One of the values provided in
BatchScheduleBenchmarkTaskRunsRequest.benchmark_task_versions
BatchScheduleBenchmarkTaskRunsRequest.benchmark_task_version_ids
"""
return self._benchmark_task_version_id

Expand All @@ -51,7 +59,7 @@ def benchmark_task_version_id(self, benchmark_task_version_id: int):
def benchmark_model_version_id(self) -> int:
r"""
One of the values provided in
BatchScheduleBenchmarkTaskRunsRequest.benchmark_model_versions
BatchScheduleBenchmarkTaskRunsRequest.benchmark_model_version_ids
"""
return self._benchmark_model_version_id

Expand All @@ -64,11 +72,42 @@ def benchmark_model_version_id(self, benchmark_model_version_id: int):
raise TypeError('benchmark_model_version_id must be of type int')
self._benchmark_model_version_id = benchmark_model_version_id

@property
def agent_id(self) -> int:
r"""
One of the values provided in
BatchScheduleBenchmarkTaskRunsRequest.benchmark_agent_ids
"""
return self._agent_id

@agent_id.setter
def agent_id(self, agent_id: int):
if agent_id is None:
del self.agent_id
return
if not isinstance(agent_id, int):
raise TypeError('agent_id must be of type int')
self._agent_id = agent_id

@property
def candidate_type(self) -> 'BenchmarkCandidateType':
"""Specifies the candidate type that was scheduled (ModelVersion vs. Agent)"""
return self._candidate_type

@candidate_type.setter
def candidate_type(self, candidate_type: 'BenchmarkCandidateType'):
if candidate_type is None:
del self.candidate_type
return
if not isinstance(candidate_type, BenchmarkCandidateType):
raise TypeError('candidate_type must be of type BenchmarkCandidateType')
self._candidate_type = candidate_type

@property
def run_scheduled(self) -> bool:
r"""
Whether the run was scheduled for the provided (benchmark_task_version,
benchmark_model_version) pair
Whether the run was scheduled for the provided (TaskVersion, Candidate)
pair.
"""
return self._run_scheduled

Expand All @@ -84,8 +123,8 @@ def run_scheduled(self, run_scheduled: bool):
@property
def run_skipped_reason(self) -> str:
r"""
If run_scheduled was false, the reason the provided
(benchmark_task_version, benchmark_model_version) pair was skipped
If run_scheduled was false, the reason the (TaskVersion, Candidate) pair
was skipped
"""
return self._run_skipped_reason or ""

Expand Down Expand Up @@ -123,5 +162,7 @@ def parent_task_version_id(self, parent_task_version_id: Optional[int]):
FieldMetadata("runSkippedReason", "run_skipped_reason", "_run_skipped_reason", str, None, PredefinedSerializer(), optional=True),
FieldMetadata("benchmarkTaskVersionId", "benchmark_task_version_id", "_benchmark_task_version_id", int, 0, PredefinedSerializer()),
FieldMetadata("parentTaskVersionId", "parent_task_version_id", "_parent_task_version_id", int, None, PredefinedSerializer(), optional=True),
FieldMetadata("agentId", "agent_id", "_agent_id", int, 0, PredefinedSerializer()),
FieldMetadata("candidateType", "candidate_type", "_candidate_type", BenchmarkCandidateType, BenchmarkCandidateType.BENCHMARK_CANDIDATE_TYPE_UNSPECIFIED, EnumSerializer()),
]

Loading