Skip to content

Commit

Permalink
data science ocpu count defaulting to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
vmleon committed Aug 4, 2023
1 parent aad057e commit d4b44a9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dev/terraform/datascience.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data "oci_datascience_notebook_session_shapes" "ds_shapes" {
compartment_id = var.compartment_ocid
filter {
name = "core_count"
values = [1]
values = [var.desired_number_cpus]
}
}

Expand Down
5 changes: 5 additions & 0 deletions dev/terraform/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ variable "riotgames_api_key" {
type = string
}

variable "desired_number_cpus" {
type = string
default = 4
}

variable "create_iam_policy" {
type = bool
default = true
Expand Down
5 changes: 3 additions & 2 deletions dev/terraform/terraform.tfvars.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ config_file_profile = "DEFAULT"
region = "REGION_NAME"
tenancy_ocid = "TENANCY_OCID"
compartment_ocid = "COMPARTMENT_OCID"
ssh_public_key = "SSH_PUBLIC_KEY"
riotgames_api_key = "RIOT_GAMES_API_KEY" # https://developer.riotgames.com/
desired_number_cpus = "DESIRED_NUMBER_CPU"
riotgames_api_key = "RIOT_GAMES_API_KEY" # https://developer.riotgames.com/
ssh_public_key = "SSH_PUBLIC_KEY"
8 changes: 8 additions & 0 deletions scripts/setenv.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const compartmentId = await searchCompartmentIdByName(
properties = { ...properties, compartmentId };
await writeEnvJson(properties);

const desiredNumberCPUs = await setVariableFromEnvOrPrompt(
"LOL_NUMBER_CPU",
"Data Science CPU number"
);

properties = { ...properties, desiredNumberCPUs: desiredNumberCPUs || 4 };
await writeEnvJson(properties);

const defaultSSHPublicKeyPath = path.join(os.homedir(), ".ssh", "id_rsa.pub");
const publicSSHKeyExists = await fs.pathExists(defaultSSHPublicKeyPath);

Expand Down
15 changes: 11 additions & 4 deletions scripts/tfvars.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ const shell = process.env.SHELL | "/bin/zsh";
$.shell = shell;
$.verbose = false;

const { tenancyId, regionName, compartmentId, riotGamesApiKey, sshPublicKey } =
await readEnvJson();
const {
tenancyId,
regionName,
compartmentId,
riotGamesApiKey,
desiredNumberCPUs,
sshPublicKey,
} = await readEnvJson();

const sshPublicKeyEscaped = sshPublicKey.replaceAll("/", "\\/");
const replaceCmdSSHPublicKey = `s/SSH_PUBLIC_KEY/${sshPublicKeyEscaped}/`;
Expand All @@ -17,8 +23,9 @@ try {
await $`sed 's/REGION_NAME/${regionName}/' dev/terraform/terraform.tfvars.template \
| sed 's/TENANCY_OCID/${tenancyId}/' \
| sed 's/COMPARTMENT_OCID/${compartmentId}/' \
| sed ${replaceCmdSSHPublicKey} \
| sed 's/RIOT_GAMES_API_KEY/${riotGamesApiKey}/' > dev/terraform/terraform.tfvars`;
| sed 's/DESIRED_NUMBER_CPU/${desiredNumberCPUs}/' \
| sed 's/RIOT_GAMES_API_KEY/${riotGamesApiKey}/' \
| sed ${replaceCmdSSHPublicKey} > dev/terraform/terraform.tfvars`;
if (exitCode !== 0) {
exitWithError(`Error creating dev/terraform/terraform.tfvars: ${stderr}`);
}
Expand Down

0 comments on commit d4b44a9

Please sign in to comment.