# kortical.api.worker_group
WARNING
Creating worker groups will incur further compute costs.
This object represents a worker group on Kortical. This is a set of computers of a given specification (e.g number of cores, RAM, GPU). You can configure various tasks, projects and environments to run on a specific worker group. For example, you might want to dedicate one worker group for training models and another for a Production environment, so performance by one is not affected by the other.
The WorkerGroup
class includes the following attributes:
id
- The ID assigned to the worker group upon creation.name
- The name of the worker group.state
- current status (e.g creating, resizing, running, terminating).worker_type
- the specification of the computers that belong to the worker group.current_size
/required_size
- the actual/desired number of computers in the worker group.
In the Kortical CLI, you can view this by running:
>>> kortical worker list
Worker Groups:
+----+------------+---------+----------------+--------------+---------------+
| id | name | state | worker_type | current_size | required_size |
+====+============+=========+================+==============+===============+
| 1 | system | Running | 4-CPU-26GB-RAM | 3 | 3 |
+----+------------+---------+----------------+--------------+---------------+
| 2 | default | Running | 4-CPU-26GB-RAM | 2 | 2 |
+----+------------+---------+----------------+--------------+---------------+
| 3 | Production | Running | 2-CPU-13GB-RAM | 2 | 2 |
+----+------------+---------+----------------+--------------+---------------+
#
# list
This function returns a full list of worker groups used in Kortical.
No Inputs
Returns
[WorkerGroup, ...]
- A list of WorkerGroup objects.
from kortical.api.worker_group import WorkerGroup
worker_groups = WorkerGroup.list()
#
# get_worker_group
This function returns the specified worker group from Kortical.
Inputs
worker_group_or_id
- Name or ID of the worker group you want.
Returns
WorkerGroup
- A WorkerGroup object.
from kortical.api.worker_group import WorkerGroup
default_worker_group = WorkerGroup.get_worker_group('default')
#
# list_worker_types
This function returns a list of worker group types.
No Inputs
Returns
[str, ...]
- A list of worker group types.
from kortical.api.worker_group import WorkerGroup
worker_types = WorkerGroup.list_worker_types()
#
# get_default_worker_type
This function gets the default worker type.
No Inputs
Returns
str
- The default type.
from kortical.api.worker_group import WorkerGroup
default_worker_type = WorkerGroup.get_default_worker_type()
#
# create_worker_group
This function creates a worker group in Kortical.
Inputs
worker_group_name
- Name of the new worker group.worker_type
- Type of the new worker group; if unsure, runworker_group.list_worker_types()
to see available options.size
- Number of computers in the new worker group.
Returns
WorkerGroup
- A WorkerGroup object.
from kortical.api.worker_group import WorkerGroup
new_worker_group = WorkerGroup.create_worker_group('production_environment', TYPE_HERE, 2)
#
# resize
This function resizes a worker group in Kortical.
Inputs
size
- Number of computers in the new worker group.
Returns
WorkerGroup
- A WorkerGroup object.
from kortical.api.worker_group import WorkerGroup
# Get the worker group
uat_environment_worker_group = WorkerGroup.get_worker_group('UAT')
# Update
uat_environment_worker_group.rersize(size=3)
#
# delete
This function deletes a worker group from Kortical.
No Inputs
Returns
None
from kortical.api.worker_group import WorkerGroup
# Get the worker group
uat_environment_worker_group = WorkerGroup.get_worker_group('UAT')
# Delete
uat_environment_worker_group.delete()