Allow enqueueing stopped tasks

More clearml stuff
This commit is contained in:
allegroai 2021-05-03 17:31:02 +03:00
parent 4b11a6efcd
commit 8f646043bb
6 changed files with 25 additions and 27 deletions

View File

@ -116,6 +116,7 @@ state_machine = {
TaskStatus.closed,
TaskStatus.created,
TaskStatus.failed,
TaskStatus.queued,
TaskStatus.in_progress,
TaskStatus.published,
TaskStatus.publishing,

View File

@ -1,8 +1,7 @@
import functools
import itertools
from concurrent.futures.thread import ThreadPoolExecutor
from operator import itemgetter
from typing import Sequence, Optional, Callable, Tuple, Dict, Any, Set, Iterable
from typing import Optional, Callable, Dict, Any, Set, Iterable
from boltons import iterutils
@ -10,24 +9,6 @@ from apiserver.database.model import AttributedDocument
from apiserver.database.model.settings import Settings
def extract_properties_to_lists(
key_names: Sequence[str],
data: Sequence[dict],
extract_func: Optional[Callable[[dict], Tuple]] = None,
) -> dict:
"""
Given a list of dictionaries and names of dictionary keys
builds a dictionary with the requested keys and values lists
:param key_names: names of the keys in the resulting dictionary
:param data: sequence of dictionaries to extract values from
:param extract_func: the optional callable that extracts properties
from a dictionary and put them in a tuple in the order corresponding to
key_names. If not specified then properties are extracted according to key_names
"""
value_sequences = zip(*map(extract_func or itemgetter(*key_names), data))
return dict(zip(key_names, map(list, value_sequences)))
class SetFieldsResolver:
"""
The class receives set fields dictionary

View File

@ -69,7 +69,7 @@
default_expiration_sec: 2592000
# cookie containing auth token, for requests arriving from a web-browser
session_auth_cookie_name: "trains_token_basic"
session_auth_cookie_name: "clearml_token_basic"
# cookie configuration for authorization cookies generated by auth.login
cookies {
@ -116,9 +116,9 @@
# Check for updates every 24 hours
check_interval_sec: 86400
url: "https://updates.trains.allegro.ai/updates"
url: "https://updates.clear.ml/updates"
component_name: "trains-server"
component_name: "clearml-server"
# GET request timeout
request_timeout_sec: 3.0
@ -128,7 +128,7 @@
# Note: statistics are sent ONLY if the user has actively opted-in
supported: true
url: "https://updates.trains.allegro.ai/stats"
url: "https://updates.clear.ml/stats"
report_interval_hours: 24
agent_relevant_threshold_days: 30

View File

@ -16,7 +16,7 @@
backupCount: 3
maxBytes: 10240000,
class: "logging.handlers.RotatingFileHandler",
filename: "/var/log/trains/apiserver.log"
filename: "/var/log/clearml/apiserver.log"
}
}
root {

View File

@ -1,3 +1,5 @@
from jsonmodels.fields import BoolField
from apiserver.apimodels.login import (
GetSupportedModesRequest,
GetSupportedModesResponse,
@ -6,12 +8,12 @@ from apiserver.apimodels.login import (
ServerErrors,
)
from apiserver.config import info
from apiserver.service_repo import endpoint
from apiserver.service_repo import endpoint, APICall
from apiserver.service_repo.auth.fixed_user import FixedUser
@endpoint("login.supported_modes", response_data_model=GetSupportedModesResponse)
def supported_modes(_, __, ___: GetSupportedModesRequest):
def supported_modes(call: APICall, _, __: GetSupportedModesRequest):
guest_user = FixedUser.get_guest_user()
if guest_user:
guest = BasicGuestMode(
@ -31,4 +33,5 @@ def supported_modes(_, __, ___: GetSupportedModesRequest):
missed_es_upgrade=info.missed_es_upgrade,
es_connection_error=info.es_connection_error,
),
authenticated=call.auth is not None,
)

View File

@ -213,3 +213,16 @@ class TestTasksEdit(TestService):
False,
)
self.assertFalse(task_in_queue)
def test_stopped_task_enqueue(self):
queue_id = self.new_queue()
task_id = self.new_task()
self.api.tasks.started(task=task_id)
self.api.tasks.stopped(task=task_id)
projection = ["*", "execution.*"]
task = self.api.tasks.get_all_ex(id=task_id, projection=projection).tasks[0]
self.assertEqual(task.status, "stopped")
self.api.tasks.enqueue(task=task_id, queue=queue_id)
task = self.api.tasks.get_all_ex(id=task_id, projection=projection).tasks[0]
self.assertEqual(task.status, "queued")
self.assertEqual(task.execution.queue, queue_id)