-
Notifications
You must be signed in to change notification settings - Fork 1
Allow >1 CPU per task, and some misc clean up #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
8eeddf7
352111a
1e42379
c826dd9
62da0eb
78ac558
e9ae0d0
2c9212c
dcea2e7
9b9f72c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
| from pathlib import Path | ||
| import textwrap | ||
|
|
||
| from invest_processes.utils import download_and_extract_datastack | ||
| from pygeoapi.process.base import BaseProcessor, ProcessorExecuteError | ||
|
|
||
| LOGGER = logging.getLogger(__name__) | ||
|
|
@@ -19,9 +18,12 @@ | |
| 'jobControlOptions': ['async-execute'], | ||
| 'keywords': ['invest'], | ||
| 'inputs': { | ||
| 'datastack_path': { | ||
| 'title': 'Datastack path', | ||
| 'description': 'The path to the datastack JSON file to execute', | ||
| 'datastack_url': { | ||
| 'title': 'Datastack URL', | ||
| 'description': ( | ||
| 'The URL to a downloadable tar.gz archive of the datastack to run. ' | ||
| 'Must be formatted as an InVEST datastack containing a JSON parameters ' | ||
| 'file called parameters.invest.json, as well as all input data files.'), | ||
| 'schema': { | ||
| 'type': 'string' | ||
| }, | ||
|
|
@@ -41,11 +43,13 @@ | |
| }, | ||
| 'example': { | ||
| 'inputs': { | ||
| 'datastack_path': '/Users/emily/invest/data/Carbon/carbon_willamette.invs.json', | ||
| 'datastack_url': 'https://raw.githubusercontent.com/natcap/invest-compute/refs/heads/main/tests/test_data/invest_carbon_datastack.tgz' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| CPUS_PER_TASK = 2 # number of cpus per task to submit to sbatch | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The relationship between the physical and virtual cores makes sense, and it also makes me wonder if we might be able to programmatically get the CPUs per task from the state of the environment somehow so that if we change the VM class, we don't also have to remember to update this module-level variable. Is that something we can easily get from the compute environment? |
||
|
|
||
|
|
||
| class ExecuteProcessor(BaseProcessor): | ||
| """InVEST execute process""" | ||
|
|
@@ -76,11 +80,15 @@ def create_slurm_script(self, datastack_url, workspace_dir): | |
| json_path = f'{workspace_dir}/datastack/parameters.invest.json' | ||
| return textwrap.dedent(f"""\ | ||
| #!/bin/sh | ||
| #SBATCH --cpus-per-task={CPUS_PER_TASK} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default |
||
|
|
||
| curl -o datastack.tgz "{datastack_url}" | ||
| mkdir {workspace_dir}/datastack | ||
| tar -xzvf datastack.tgz -C {workspace_dir}/datastack | ||
| rm datastack.tgz | ||
|
|
||
| eval "$(~/bin/micromamba shell hook -s posix)" | ||
| micromamba activate invest_env | ||
| MODEL_ID=$(python -c "from natcap.invest import datastack; print(datastack.extract_parameter_set('{json_path}').model_id)") | ||
| invest --debug --taskgraph-log-level=DEBUG run \ | ||
| --datastack {json_path} \ | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/bin/bash | ||
|
|
||
| scl enable gcc-toolset-12 bash | ||
|
|
||
| # install micromamba | ||
| curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj ~/bin/micromamba | ||
| eval "$(~/bin/micromamba shell hook -s posix)" | ||
| micromamba --version | ||
|
|
||
| # create and activate the environment | ||
| micromamba create -y -n invest_env python=3.13 gdal | ||
| micromamba activate invest_env | ||
| pip install setuptools setuptools_scm build cython babel | ||
| pip install --no-build-isolation git+https://github.com/natcap/pygeoprocessing.git | ||
| pip install --no-build-isolation git+https://github.com/emlys/invest.git@bugfix/2572 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Install the not-yet-released changes that fixed the memory leak issue |
||
| invest --version | ||
|
|
||
| # activate the environment in future shells | ||
| echo 'echo "activating micromamba env"' >> /etc/bashrc | ||
| echo 'eval "$(~/bin/micromamba shell hook -s posix)" && micromamba activate invest_env' >> ~/.bashrc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,18 +58,20 @@ module "homefs" { | |
| region = var.region | ||
| reserved_ip_range = module.private_service_access.reserved_ip_range | ||
| zone = var.zone | ||
| size_gb = 2560 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly request the minimum filestore size, 2560 GB. |
||
| } | ||
|
|
||
| module "debug_nodeset" { | ||
| source = "github.com/GoogleCloudPlatform/cluster-toolkit//community/modules/compute/schedmd-slurm-gcp-v6-nodeset?ref=v1.90.0" | ||
| allow_automatic_updates = false | ||
| labels = var.labels | ||
| machine_type = "c2-standard-8" | ||
| machine_type = "c2-standard-4" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Downgraded for cost savings. |
||
| disk_type = "pd-ssd" | ||
| name = "debug_nodeset" | ||
| node_count_dynamic_max = 4 | ||
| project_id = var.project_id | ||
| region = var.region | ||
| startup_script = "/home/bin/startup_script.sh" | ||
| subnetwork_self_link = module.network.subnetwork_self_link | ||
| zone = var.zone | ||
| } | ||
|
|
@@ -87,12 +89,12 @@ module "compute_nodeset" { | |
| allow_automatic_updates = false | ||
| bandwidth_tier = "gvnic_enabled" | ||
| labels = var.labels | ||
| machine_type = "c2-standard-8" | ||
| machine_type = "c2-standard-4" | ||
| name = "compute_nodeset" | ||
| node_count_dynamic_max = 20 | ||
| project_id = var.project_id | ||
| region = var.region | ||
| startup_script = "startup_script.sh" | ||
| startup_script = "/home/bin/startup_script.sh" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to an absolute path to prevent issues depending where this is run from. |
||
| subnetwork_self_link = module.network.subnetwork_self_link | ||
| zone = var.zone | ||
| } | ||
|
|
@@ -128,7 +130,7 @@ module "slurm_login" { | |
| source = "github.com/GoogleCloudPlatform/cluster-toolkit//community/modules/scheduler/schedmd-slurm-gcp-v6-login?ref=v1.90.0" | ||
| enable_login_public_ips = true | ||
| labels = var.labels | ||
| machine_type = "n2-standard-4" | ||
| machine_type = "n2-standard-2" | ||
| name_prefix = "slurm_login" | ||
| project_id = var.project_id | ||
| region = var.region | ||
|
|
@@ -143,6 +145,7 @@ module "slurm_controller" { | |
| enable_controller_public_ips = true | ||
| labels = var.labels | ||
| login_nodes = flatten([module.slurm_login.login_nodes]) | ||
| machine_type = "n2-standard-2" | ||
| network_storage = flatten([module.homefs.network_storage]) | ||
| nodeset = flatten([module.h3_partition.nodeset, flatten([module.compute_partition.nodeset, flatten([module.debug_partition.nodeset])])]) | ||
| nodeset_dyn = flatten([module.h3_partition.nodeset_dyn, flatten([module.compute_partition.nodeset_dyn, flatten([module.debug_partition.nodeset_dyn])])]) | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer a dependency since
download_and_extract_datastackwas removed