From 42adcef9763a7b2e36139e864fcb5d44745e01d7 Mon Sep 17 00:00:00 2001 From: Sajid Ali Date: Thu, 21 May 2026 11:58:11 -0400 Subject: [PATCH] pull in recent changes from slurmrest plugin --- .gitignore | 1 + Containerfile.debugpy | 3 ++ coldfront/config/core.py | 2 +- coldfront/config/plugins/slurmrest.py | 6 ++- .../management/commands/load_test_data.py | 46 +++++++------------ uv.lock | 2 +- 6 files changed, 27 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index d8c9707614..35abdf1c95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.memsearch/ *.py[cod] *.swp coldfront.egg-info diff --git a/Containerfile.debugpy b/Containerfile.debugpy index c853205631..99c20a9fe1 100644 --- a/Containerfile.debugpy +++ b/Containerfile.debugpy @@ -49,6 +49,9 @@ ENV PLUGIN_XDMOD=True ENV PLUGIN_API=True ENV EMAIL_ENABLED=True ENV XDMOD_API_URL="localhost" +ENV SLURMREST_CLUSTERS="UniversityHPC" +ENV SLURM_UNIVERSITYHPC_ENDPOINT="localhost" +ENV SLURM_UNIVERSITYHPC_TOKEN="dummy" EXPOSE 8000 EXPOSE 5678 diff --git a/coldfront/config/core.py b/coldfront/config/core.py index 986b4a1219..dd81f22836 100644 --- a/coldfront/config/core.py +++ b/coldfront/config/core.py @@ -20,7 +20,7 @@ # ------------------------------------------------------------------------------ # Default HPC resource configuration # ------------------------------------------------------------------------------ -GENERAL_RESOURCE_NAME = ENV.str("GENERAL_RESOURCE_NAME", default="University HPC") +GENERAL_RESOURCE_NAME = ENV.str("GENERAL_RESOURCE_NAME", default="UniversityHPC") # ------------------------------------------------------------------------------ # Enable Research Outputs, Grants, Publications diff --git a/coldfront/config/plugins/slurmrest.py b/coldfront/config/plugins/slurmrest.py index e4dce943fe..fe10badf38 100644 --- a/coldfront/config/plugins/slurmrest.py +++ b/coldfront/config/plugins/slurmrest.py @@ -1,3 +1,5 @@ +import sys + from coldfront.config.base import INSTALLED_APPS from coldfront.config.env import ENV # noqa: F401 from coldfront.config.logging import LOGGING @@ -20,7 +22,9 @@ SLURMREST_CLUSTERS = {} for cluster in filter(None, ENV.str("SLURMREST_CLUSTERS", "").split(",")): cluster_name = f"SLURM_{cluster.upper()}" - cluster_type = ENV.str(f"{cluster_name}_TYPE") + if (ENV.str(f"{cluster_name}_ENDPOINT") is None) or (ENV.str(f"{cluster_name}_TOKEN") is None): + sys.exit(1) + SLURMREST_CLUSTERS[cluster] = { "name": cluster, "base_url": ENV.str(f"{cluster_name}_ENDPOINT"), diff --git a/coldfront/core/utils/management/commands/load_test_data.py b/coldfront/core/utils/management/commands/load_test_data.py index 4cdb77ec0b..a50fccd690 100644 --- a/coldfront/core/utils/management/commands/load_test_data.py +++ b/coldfront/core/utils/management/commands/load_test_data.py @@ -219,6 +219,12 @@ def handle(self, *args, **options): is_allocatable=is_allocatable, ) + ResourceAttribute.objects.get_or_create( + resource_attribute_type=ResourceAttributeType.objects.get(name="slurm_cluster"), + resource=Resource.objects.get(name=GENERAL_RESOURCE_NAME), + value=GENERAL_RESOURCE_NAME, + ) + pi1 = User.objects.get(username="cgray") pi1.userprofile.is_pi = True pi1.save() @@ -282,45 +288,35 @@ def handle(self, *args, **options): allocation_obj.resources.add(Resource.objects.get(name=GENERAL_RESOURCE_NAME)) allocation_obj.save() - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="slurm_specs" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="slurm_specs") AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, value="Fairshare=100:QOS+=supporters", ) - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="slurm_user_specs" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="slurm_user_specs") AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, value="Fairshare=parent", ) - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="slurm_account_name" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="slurm_account_name") AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, value=f"torch_pr_{allocation_obj.project.pk}_general", ) - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="SupportersQOS" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="SupportersQOS") AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, value="Yes", ) - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="SupportersQOSExpireDate" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="SupportersQOSExpireDate") AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, @@ -344,17 +340,13 @@ def handle(self, *args, **options): ) allocation_obj.resources.add(Resource.objects.get(name="Tandon")) allocation_obj.save() - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="slurm_account_name" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="slurm_account_name") AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, value=f"torch_pr_{allocation_obj.project.pk}_Tandon", ) - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="Core Usage (Hours)" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="Core Usage (Hours)") AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, @@ -437,9 +429,7 @@ def handle(self, *args, **options): grant_number="12345", role="PI", grant_pi_full_name="Stephanie Foster", - funding_agency=GrantFundingAgency.objects.get( - name="Department of Defense (DoD)" - ), + funding_agency=GrantFundingAgency.objects.get(name="Department of Defense (DoD)"), grant_start=start_date, grant_end=end_date, percent_credit=20.0, @@ -461,18 +451,14 @@ def handle(self, *args, **options): allocation_obj.resources.add(Resource.objects.get(name=GENERAL_RESOURCE_NAME)) allocation_obj.save() - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="slurm_account_name" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="slurm_account_name") AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, value=f"torch_pr_{allocation_obj.project.pk}_general", ) - allocation_attribute_type_obj = AllocationAttributeType.objects.get( - name="Core Usage (Hours)" - ) + allocation_attribute_type_obj = AllocationAttributeType.objects.get(name="Core Usage (Hours)") allocation_attribute_obj, _ = AllocationAttribute.objects.get_or_create( allocation_attribute_type=allocation_attribute_type_obj, allocation=allocation_obj, diff --git a/uv.lock b/uv.lock index c8f1c246f3..eb93affa65 100644 --- a/uv.lock +++ b/uv.lock @@ -316,7 +316,7 @@ dev = [ [[package]] name = "coldfront-plugin-slurmrest" version = "0.0.1" -source = { git = "https://github.com/NYU-RTS/rts-coldfront-slurm-plugin#036bb6c3367b382b7a1c8d9b4a6ba2aac1f0c370" } +source = { git = "https://github.com/NYU-RTS/rts-coldfront-slurm-plugin#74f4ee9e5cc193155aed35ef0d0b2f9dc2ec71ef" } dependencies = [ { name = "coldfront" }, { name = "slurmrest-python" },