Skip to content

Commit

Permalink
Merge pull request 2i2c-org#3335 from GeorgianaElena/relocate-resourc…
Browse files Browse the repository at this point in the history
…e-allocation-script-deployer

[deployer] Relocate resource allocation script
  • Loading branch information
GeorgianaElena authored Oct 27, 2023
2 parents f53f124 + 1a38086 commit d5ef0c9
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 13 deletions.
22 changes: 18 additions & 4 deletions deployer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ The `deployer.py` file is the main file, that contains all of the commands regis
│   │   │   ├── dedicate_cluster_app.py
│   │   │   └── gcp.py
│   │   └── helm_upgrade
│   │   ├── decision.py
│   │   └── jobs.py
│   │   | ├── decision.py
│   │   | └── jobs.py
| | └── resource_allocation
│   │   ├── generate_choices.py
│   │   ├── node-capacity-info.json
│   │   ├── resource_allocation_app.py
│   │   └── update_nodeinfo.py
│   ├── grafana
│   │   ├── central_grafana.py
│   │   ├── deploy_dashboards.py
Expand Down Expand Up @@ -139,8 +144,8 @@ This section descripts some of the subcommands the `deployer` can carry out.
│ deploy-support Deploy support components to a cluster │
│ exec Execute a shell in various parts of the infra. It can be used for poking around, or │
│ debugging issues. │
│ generate Generate various types of assets. It currently supports generating files related to billing
or new, dedicated clusters.
│ generate Generate various types of assets. It currently supports generating files related to
billing, new dedicated clusters, helm upgrade strategies and resource allocation.
│ grafana Manages Grafana related workflows. │
│ run-hub-health-check Run a health check on a given hub on a given cluster. Optionally check scaling of dask │
│ workers if the hub is a daskhub. │
Expand Down Expand Up @@ -252,6 +257,15 @@ These defaults are described in each file template.
The cluster configuration directory is generated based on the templates in:
- (`config/clusters/templates/gcp`)[https://github.com/2i2c-org/infrastructure/blob/master/config/clusters/templates/gcp]

#### `generate resource-allocation`

This sub-command can be used to generate the resource allocation choices for given instance type and a given optimization strategy.

##### `generate resource-allocation choices`
This generates a custom number of resource allocation choices for a certain instance type, depending on a certain chosen strategy that can be used in the profile list of a hub.

##### `generate resource-allocation node-info-update`
This updates the json file `node-capacity-info.json` with info about the capacity of a node of a certain type. This file is then used for generating the resource choices.

### The `grafana` sub-command
This deployer sub-command manages all of the available functions related to Grafana.
Expand Down
4 changes: 2 additions & 2 deletions deployer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import deployer.commands.generate.dedicated_cluster.aws # noqa: F401
import deployer.commands.generate.dedicated_cluster.gcp # noqa: F401
import deployer.commands.generate.helm_upgrade.jobs # noqa: F401
import deployer.commands.generate.resource_allocation.generate_choices # noqa: F401
import deployer.commands.generate.resource_allocation.update_nodeinfo # noqa: F401
import deployer.commands.grafana.central_grafana # noqa: F401
import deployer.commands.grafana.deploy_dashboards # noqa: F401
import deployer.commands.grafana.tokens # noqa: F401
import deployer.commands.validate.config # noqa: F401
import deployer.keys.decrypt_age # noqa: F401
import deployer.resource_allocation.generate_choices # noqa: F401
import deployer.resource_allocation.update_nodeinfo # noqa: F401

from .cli_app import app

Expand Down
3 changes: 2 additions & 1 deletion deployer/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
app.add_typer(
generate_app,
name="generate",
help="Generate various types of assets. It currently supports generating files related to billing or new, dedicated clusters.",
help="Generate various types of assets. It currently supports generating files related to billing, "
"new dedicated clusters, helm upgrade strategies and resource allocation.",
)
app.add_typer(
cilogon_client_app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import typer
from ruamel.yaml import YAML

from ..cli_app import app
from .resource_allocation_app import resource_allocation_app

yaml = YAML(typ="rt")

Expand Down Expand Up @@ -99,8 +99,8 @@ def proportional_memory_strategy(
return choices


@app.command()
def generate_resource_allocation_choices(
@resource_allocation_app.command()
def choices(
instance_type: str = typer.Argument(
..., help="Instance type to generate Resource Allocation options for"
),
Expand All @@ -110,6 +110,10 @@ def generate_resource_allocation_choices(
help="Strategy to use for generating resource allocation choices choices",
),
):
"""
Generate a custom number of resource allocation choices for a certain instance type,
depending on a certain chosen strategy.
"""
with open(HERE / "node-capacity-info.json") as f:
nodeinfo = json.load(f)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Creates a new typer application, which is then
nested as a sub-command named "resource-allocation"
under the `generate` sub-command of the deployer.
"""
import typer

from deployer.cli_app import generate_app

resource_allocation_app = typer.Typer(pretty_exceptions_show_locals=False)
generate_app.add_typer(
resource_allocation_app,
name="resource-allocation",
help="Generate the choices for a resource allocation strategy of an instance type and additional helper information",
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from kubernetes.utils.quantity import parse_quantity
from ruamel.yaml import YAML

from ..cli_app import app
from .resource_allocation_app import resource_allocation_app

HERE = Path(__file__).parent

Expand Down Expand Up @@ -133,12 +133,17 @@ def get_node_capacity_info(instance_type: str):
}


@app.command()
def update_node_capacity_info(
@resource_allocation_app.command()
def node_info_update(
instance_type: str = typer.Argument(
..., help="Instance type to generate Resource Allocation options for"
),
):
"""
Generates a new entry holding info about the capacity of a node of a certain instance type
or updates an existing one that is then used to update a json file called `node-capacity-info.json`.
This file is then used for generating the resource choices.
"""
try:
with open(HERE / "node-capacity-info.json") as f:
instances_info = json.load(f)
Expand Down
Empty file.

0 comments on commit d5ef0c9

Please sign in to comment.