yr.create_resource_group

yr.create_resource_group#

yr.create_resource_group(bundles: List[Dict[str, float]], name: str | None = None, strategy: str | None = 'PACK') ResourceGroup[source]#

Asynchronously create a ResourceGroup.

Note

  • bundle_index is the index of each bundle in the list bundles.

  • Valid resource names include: “CPU”, “Memory”, and custom resources. Custom resources currently support “GPU/XX/YY” and “NPU/XX/YY”, where “XX” is the card model, such as “Ascend910B4”, and “YY” can be “count”, “latency”, or “stream”.

  • For each bundle, if “CPU” or “Memory” is not set, or is set to 0, they will be assigned 300 and 128 respectively.

  • The amount of resources in each bundle must be greater than 0; if less than 0, an exception will be thrown. Resource names must not be empty; if empty, an exception will be thrown.

  • Other resources besides “CPU” and “Memory” will be filtered out if set to 0.

Parameters:
  • bundles (List[Dict[str, float]]) – A set of bundles representing resource requests, must not be empty.

  • name (Optional[str], optional) – The name of the ResourceGroup to be created, which must be unique and cannot be ‘primary’ or an empty string. This parameter is optional, with a default value of None, meaning a rgroup-{uuid} type string will be randomly generated as the resource group name.

  • strategy (OptionsOptional[str], optional) –

    The strategy to create the resource group, defalut strategy is PACK

    • 'None': No strategy.

    • 'PACK': Pack multiple bundles into the same node as much as possible.

    • 'SPREAD': Distribute multiple bundles across different nodes as much as possible.

    • 'STRICT_PACK': All bundles must be placed on the same node, otherwise creation fails.

    • 'STRICT_SPREAD': All bundles must be placed on different nodes, otherwise creation fails.

Returns:

A ResourceGroup handle.

Raises:
  • TypeError – If the parameter type is incorrect.

  • ValueError – If the parameter is empty.

  • RuntimeError – If there are insufficient resources to create the resource group.

  • RuntimeError – If the resource group is created repeatedly.

  • RuntimeError – If the resource group name is invalid.

Examples

>>> rg1 = yr.create_resource_group([{"NPU/Ascend910B4/count":1},{"CPU":2000,"Memory":2000}])
>>>
>>> rg2 = yr.create_resource_group([{"NPU/Ascend910B4/count":1},{"CPU":2000,"Memory":2000}], "rgname")