Skip to content
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

add cluster-related changes #357

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b2f6f7c
add agilemonkeys changes
claire-peters Jan 29, 2025
dca3362
fix import
claire-peters Feb 1, 2025
dbfd65b
remove customlogger import
claire-peters Feb 1, 2025
cffa172
remove Projects in Allocations table
claire-peters Feb 4, 2025
cf3f432
fix allocation size attribute recognition
claire-peters Feb 4, 2025
a3a6c3d
improve add_resource_defaults resourceattributetype create/update fun…
claire-peters Feb 4, 2025
b326bb2
lengthen account name recognition
claire-peters Feb 4, 2025
a07eaf4
fix cluster identification, allocation identification
claire-peters Feb 4, 2025
675f0a7
change query for resource allocation table to improve performance
claire-peters Feb 4, 2025
e46094d
change ProjectDetailView resource table contents
claire-peters Feb 4, 2025
2d3557f
change partition recognition
claire-peters Feb 4, 2025
53eb5d3
fix resource_attribute_type ref
claire-peters Feb 5, 2025
792043d
remove project_resources table
claire-peters Feb 5, 2025
d44e2a5
change allocation addition/update recognition
claire-peters Feb 5, 2025
579f177
update Allow/Deny Accounts/Groups interpretation
claire-peters Feb 5, 2025
9da0ddd
fix resource allocation table visibility
claire-peters Feb 5, 2025
57fb286
add logic for user deactivation
claire-peters Feb 5, 2025
05d987a
count only active allocationusers in resourcedetail allocation table
claire-peters Feb 5, 2025
fa8c157
fix cluster allocation display
claire-peters Feb 5, 2025
c95229b
fix allocationuser count badge
claire-peters Feb 5, 2025
e8ba7bc
change cluster allocation table heading
claire-peters Feb 5, 2025
d979fcf
change allocation_resource_ordering
claire-peters Feb 5, 2025
d4f4d15
make new cluster allocations active, not new
claire-peters Feb 5, 2025
85befdc
don't create allocations for projects without corresponding slurm acc…
claire-peters Feb 5, 2025
075ba7f
fix time_chart_data display bug
claire-peters Feb 6, 2025
9284ce7
fix numerical typing in resource allocation table
claire-peters Feb 6, 2025
5afd76a
fix datatables display on resource_detail
claire-peters Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion coldfront/core/allocation/forms.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import logging
import re

from django import forms
from django.conf import settings
from django.db.models.functions import Lower
from django.shortcuts import get_object_or_404
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator, MaxValueValidator

from coldfront.core.allocation.models import (
AllocationAccount,
AllocationAttributeType,
AllocationAttribute,
AllocationStatusChoice
AllocationStatusChoice,
AllocationUserAttribute,
AllocationUser
)
from coldfront.core.allocation.utils import get_user_resources
from coldfront.core.project.models import Project
Expand All @@ -28,6 +32,8 @@
HSPH_CODE = import_from_settings('HSPH_CODE', '000-000-000-000-000-000-000-000-000-000-000')
SEAS_CODE = import_from_settings('SEAS_CODE', '111-111-111-111-111-111-111-111-111-111-111')

logger = logging.getLogger(__name__)


class ExpenseCodeField(forms.CharField):
"""custom field for expense_code"""
Expand Down Expand Up @@ -56,6 +62,28 @@ def clean(self, value):
# formatted_value = insert_dashes(digits_only)
return value


class AllocationUserRawSareField(forms.CharField):
"""custom field for rawshare"""

def validate(self, value):
try:
integer_value = int(value)
if integer_value < 0:
raise ValidationError('RawShare value must be a positive integer number or the string "parent".')
if integer_value > 1410065399:
raise ValidationError('RawShare value must be a positive integer number below 1410065399 or the string "parent".')
except ValueError:
if value not in ['parent']:
raise ValidationError('RawShare value must be a positive integer number or the string "parent".')
except Exception:
raise ValidationError('Invalid RawShare value detected. It must be a positive integer number or the string "parent".')

def clean(self, value):
value = super().clean(value)
return value


ALLOCATION_SPECIFICATIONS = [
('Heavy IO', 'My lab will perform heavy I/O from the cluster against this space (more than 100 cores)'),
('Mounted', 'My lab intends to mount the storage to our local machine as an additional drive'),
Expand Down Expand Up @@ -277,6 +305,17 @@ class AllocationAddUserForm(forms.Form):
email = forms.EmailField(max_length=100, required=False, disabled=True)
selected = forms.BooleanField(initial=False, required=False)

class AllocationAddNonProjectUserForm(forms.Form):
username = forms.CharField(max_length=150, disabled=True)
first_name = forms.CharField(max_length=150, required=False, disabled=True)
last_name = forms.CharField(max_length=150, required=False, disabled=True)
email = forms.EmailField(max_length=100, required=False, disabled=True)
selected = forms.BooleanField(initial=False, required=False)


class AllocationEditUserForm(forms.Form):
fairshare = forms.CharField(max_length=10, required=True)


class AllocationRemoveUserForm(forms.Form):
username = forms.CharField(max_length=150, disabled=True)
Expand Down Expand Up @@ -402,6 +441,15 @@ def clean(self):
allocation_attribute.clean()


class AllocationUserAttributeUpdateForm(forms.Form):
attribute_pk = forms.IntegerField(required=True)
value = AllocationUserRawSareField(required=True)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['attribute_pk'].widget = forms.HiddenInput()


class AllocationChangeForm(forms.Form):
EXTENSION_CHOICES = [
(0, 'No Extension')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ def handle(self, *args, **options):
for choice in ('Active', 'Error', 'Removed', ):
AllocationUserStatusChoice.objects.get_or_create(name=choice)

for name, attribute_type, is_private in (
('FairShare', 'Float', False),
('NormShares', 'Float', False),
('EffectvUsage', 'Float', False),
('RawUsage', 'Int', False),
for name, attribute_type, is_private, is_changeable in (
('slurm_specs', 'Attribute Expanded Text', False, True),
):
AllocationUserAttributeType.objects.update_or_create(
name=name,
Expand Down Expand Up @@ -92,7 +89,7 @@ def handle(self, *args, **options):
# ('Purchase Order Number', 'Int', False, True),
# ('send_expiry_email_on_date', 'Date', False, True),
('slurm_account_name', 'Text', False, False),
# ('slurm_specs', 'Attribute Expanded Text', False, True),
('slurm_specs', 'Attribute Expanded Text', False, True),
# ('slurm_specs_attriblist', 'Text', False, True),
# ('slurm_user_specs', 'Attribute Expanded Text', False, True),
# ('slurm_user_specs_attriblist', 'Text', False, True),
Expand Down
Loading