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 more descriptive output for when no allocations are found #272

Merged
merged 24 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
50bb450
Merge pull request #40 from pitt-crc/develop
djperrefort Jun 11, 2022
bc12c60
Merge branch 'main' of https://github.com/pitt-crc/wrappers into main
Comeani Apr 3, 2023
a14cf8c
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Jun 13, 2023
def7d91
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Jun 20, 2023
80d0675
Merge branch 'main' of https://github.com/pitt-crc/wrappers into main
Comeani Jul 12, 2023
a30c9ec
Merge branch 'main' of https://github.com/pitt-crc/wrappers into main
Comeani Jul 18, 2023
03bbaff
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Aug 29, 2023
74d1758
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Aug 29, 2023
256c639
Merge branch 'main' of https://github.com/pitt-crc/wrappers into main
Comeani May 6, 2024
c5a2cc4
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani May 14, 2024
9c78d99
add more detailed message specifically for if a research group id was…
Comeani May 15, 2024
33d7a52
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Jun 7, 2024
05a4364
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Jun 13, 2024
52f0598
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Jun 13, 2024
ae0d7e1
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Aug 21, 2024
6dbebdc
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Sep 4, 2024
b51e26b
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Oct 4, 2024
0285db4
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Oct 15, 2024
e32a9d9
Merge branch 'main' of https://github.com/pitt-crc/wrappers
Comeani Nov 11, 2024
fb19bac
add error messages to crc-sus and crc-proposal-end
Comeani Nov 11, 2024
30859d6
CRC -> CRCD
Comeani Nov 11, 2024
3d842ab
fix long lines
Comeani Nov 11, 2024
91251e2
more long lines apparently
Comeani Nov 11, 2024
d13f702
long line
Comeani Nov 11, 2024
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
17 changes: 12 additions & 5 deletions apps/crc_proposal_end.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Print the end date for an account's proposal.

This application is designed to interface with the CRC banking application
This application is designed to interface with the CRCD banking application
and will not work without a running bank installation.
"""

Expand All @@ -15,7 +15,7 @@


class CrcProposalEnd(BaseParser):
"""Display the end date for an account's current CRC proposal."""
"""Display the end date for an account's current CRCD proposal."""

def __init__(self) -> None:
"""Define arguments for the command line interface"""
Expand All @@ -34,15 +34,22 @@ def app_logic(self, args: Namespace) -> None:

Slurm.check_slurm_account_exists(args.account)
keystone_session = KeystoneClient(url=KEYSTONE_URL)
keystone_session.login(username=os.environ["USER"], password=getpass("Please enter your CRC login password:\n"))
keystone_session.login(username=os.environ["USER"],
password=getpass("Please enter your CRCD login password:\n"))

team_id = get_team_id(keystone_session, args.account)
alloc_requests = get_active_requests(keystone_session, team_id)

if not alloc_requests:
print(f"\033[91m\033[1mNo active allocation information found in accounting system for '{args.account}'!\n")
print("Showing end date for most recently expired Resource Allocation Request:\033[0m")
alloc_requests = [get_most_recent_expired_request(keystone_session, team_id)]
print("Showing end date for most recently expired Resource Allocation Request:\033[0m \n")
try:
alloc_requests = [get_most_recent_expired_request(keystone_session, team_id)]
except IndexError:
print("\033[91m\033[1mNo allocation information found. Either the group does not have any allocations, "
"or you do not have permissions to view them. If you believe this to be a mistake, please submit a "
"help ticket to the CRCD team. \033[0m \n")
exit()

for request in alloc_requests:
print(f"'{request['title']}' ends on {request['expire']} ")
14 changes: 11 additions & 3 deletions apps/crc_sus.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,23 @@ def app_logic(self, args: Namespace) -> None:

Slurm.check_slurm_account_exists(account_name=args.account)
keystone_session = KeystoneClient(url=KEYSTONE_URL)
keystone_session.login(username=os.environ["USER"], password=getpass("Please enter your CRC login password:\n"))
keystone_session.login(username=os.environ["USER"],
password=getpass("Please enter your CRCD login password:\n"))

group_id = get_team_id(keystone_session, args.account)
alloc_requests = get_active_requests(keystone_session, group_id)

if not alloc_requests:
print(f"\033[91m\033[1mNo active allocation information found in accounting system for '{args.account}'!\n")
print("Showing remaining service unit amounts for most recently expired Resource Allocation Request:\033[0m")
alloc_requests = [get_most_recent_expired_request(keystone_session, group_id)]
print("Showing remaining service unit amounts for most recently expired Resource Allocation Request:"
"\033[0m \n")
try:
alloc_requests = [get_most_recent_expired_request(keystone_session, group_id)]
except IndexError:
print("\033[91m\033[1mNo allocation information found. Either the group does not have any allocations, "
"or you do not have permissions to view them. If you believe this to be a mistake, please submit "
"a help ticket to the CRCD team. \033[0m \n")
exit()

per_cluster_totals = get_per_cluster_totals(keystone_session, alloc_requests,
get_enabled_cluster_ids(keystone_session))
Expand Down
14 changes: 10 additions & 4 deletions apps/crc_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from prettytable import PrettyTable

from keystone_client import KeystoneClient
from .utils.cli import BaseParser
from .utils.keystone import *
from .utils.system_info import Slurm
Expand Down Expand Up @@ -98,16 +97,23 @@ def app_logic(self, args: Namespace) -> None:

Slurm.check_slurm_account_exists(account_name=args.account)
keystone_session = KeystoneClient(url=KEYSTONE_URL)
keystone_session.login(username=os.environ["USER"], password=getpass("Please enter your CRC login password:\n"))
keystone_session.login(username=os.environ["USER"],
password=getpass("Please enter your CRCD login password:\n"))

# Gather AllocationRequests from Keystone
group_id = get_team_id(keystone_session, args.account)
alloc_requests = get_active_requests(keystone_session, group_id)

if not alloc_requests:
print(f"\033[91m\033[1mNo active allocation information found in accounting system for '{args.account}'!\n")
print("Showing usage information for most recently expired Resource Allocation Request: \033[0m")
alloc_requests = [get_most_recent_expired_request(keystone_session, group_id)]
print("Attempting to show the most recently expired Resource Allocation Request info: \033[0m \n")
try:
alloc_requests = [get_most_recent_expired_request(keystone_session, group_id)]
except IndexError:
print("\033[91m\033[1mNo allocation information found. Either the group does not have any allocations, "
"or you do not have permissions to view them. If you believe this to be a mistake, please submit "
"a help ticket to the CRCD team. \033[0m \n")
exit()

clusters = get_enabled_cluster_ids(keystone_session)

Expand Down