Skip to content

Commit

Permalink
Merge branch 'main' into new_python_versions
Browse files Browse the repository at this point in the history
  • Loading branch information
djperrefort authored Oct 3, 2023
2 parents a99b6a9 + f38f021 commit 085dbc1
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CodeQL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/DocumentationBuild.yml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout project source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/PackagePublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/PackageTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
fail-fast: false
matrix:
slurm_version:
- "20.02.5.1"
- "20.11.9.1"
- "22.05.2.1"
- 20.11.9.1
- 22.05.2.1
- 23.02.5.1
python_version:
- "3.8"
- "3.9"
Expand All @@ -36,7 +36,7 @@ jobs:
run: mkdir -p /ihome/crc/bank

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install poetry
run: |
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![](https://app.codacy.com/project/badge/Grade/230da08d818542d4a4bb556880943dd5)](https://www.codacy.com/gh/pitt-crc/wrappers/dashboard?utm_source=github.com&utm_medium=referral&utm_content=pitt-crc/wrappers&utm_campaign=Badge_Grade)
[![](https://app.codacy.com/project/badge/Coverage/230da08d818542d4a4bb556880943dd5)](https://www.codacy.com/gh/pitt-crc/wrappers/dashboard?utm_source=github.com&utm_medium=referral&utm_content=pitt-crc/wrappers&utm_campaign=Badge_Coverage)
[![](https://github.com/pitt-crc/wrappers/actions/workflows/CodeQL.yml/badge.svg)](https://github.com/pitt-crc/wrappers/actions/workflows/CodeQL.yml)

Command line wrapper applications that simplify common HPC user tasks on Slurm based systems.

Expand Down
8 changes: 6 additions & 2 deletions apps/crc_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CrcInteractive(BaseParser):
default_time = time(1) # Default runtime
default_nodes = 1 # Default number of nodes
default_cores = 1 # Default number of requested cores
default_mpi_cores = 28 # Default number of request cores on an MPI partition
default_mpi_cores = 28 # Default number of request cores on an MPI partition
default_mem = 1 # Default memory in GB
default_gpus = 0 # Default number of GPUs

Expand Down Expand Up @@ -91,8 +91,12 @@ def parse_time(time_str: str) -> time:
ArgumentTypeError: If the input string is not in the correct format or cannot be parsed.
"""

time_list = time_str.split(':')
if len(time_list) > 3:
raise ArgumentTypeError(f'Could not parse time value {time_str}')

try:
return time(*time_str.split(':')[0])
return time(*map(int, time_list))

except Exception:
raise ArgumentTypeError(f'Could not parse time value {time_str}')
Expand Down
1 change: 0 additions & 1 deletion apps/crc_proposal_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import grp
import os
from argparse import Namespace
from datetime import datetime

from bank.account_logic import AccountServices

Expand Down
1 change: 1 addition & 0 deletions apps/crc_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .utils.cli import BaseParser
from .utils.system_info import Shell


class CrcUsage(BaseParser):
"""Display a Slurm account's cluster usage."""

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ coverage = "*"
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = "6.2.1"
sphinx-autoapi = "2.1.1"
sphinx = "7.1.2"
sphinx-autoapi = "3.0.0"
sphinx-copybutton = "0.5.2"
sphinx-rtd-theme = "1.3.0"
46 changes: 46 additions & 0 deletions tests/test_crc_interactive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Tests for the ``crc-interactive`` application."""

import unittest
from argparse import ArgumentTypeError
from datetime import time
from unittest import TestCase

from apps.crc_interactive import CrcInteractive
Expand All @@ -17,3 +20,46 @@ def test_args_match_class_settings(self) -> None:
self.assertEqual(CrcInteractive.default_cores, args.num_cores)
self.assertEqual(CrcInteractive.default_mem, args.mem)
self.assertEqual(CrcInteractive.default_gpus, args.num_gpus)


class TestParseTime(unittest.TestCase):
"""Test the parsing of time strings"""

def test_valid_time(self) -> None:
"""Test the parsing of valid time strings"""

self.assertEqual(CrcInteractive.parse_time('1'), time(1, 0, 0))
self.assertEqual(CrcInteractive.parse_time('01'), time(1, 0, 0))
self.assertEqual(CrcInteractive.parse_time('23:59'), time(23, 59, 0))
self.assertEqual(CrcInteractive.parse_time('12:34:56'), time(12, 34, 56))

def test_invalid_time_format(self) -> None:
"""Test an errr is raised for invalid time formatting"""

# Test with invalid time formats
with self.assertRaises(ArgumentTypeError, msg='Error not raised for invalid delimiter'):
CrcInteractive.parse_time('12-34-56')

with self.assertRaises(ArgumentTypeError, msg='Error not raised for too many digits'):
CrcInteractive.parse_time('123:456:789')

with self.assertRaises(ArgumentTypeError, msg='Error not raised for too many segments'):
CrcInteractive.parse_time('12:34:56:78')

def test_invalid_time_value(self) -> None:
"""Test an errr is raised for invalid time values"""

with self.assertRaises(ArgumentTypeError, msg='Error not raised for invalid hour'):
CrcInteractive.parse_time('25:00:00')

with self.assertRaises(ArgumentTypeError, msg='Error not raised for invalid minute'):
CrcInteractive.parse_time('12:60:00')

with self.assertRaises(ArgumentTypeError, msg='Error not raised for invalid second'):
CrcInteractive.parse_time('12:34:60')

def test_empty_string(self) -> None:
"""Test an error is raised for empty strings"""

with self.assertRaises(ArgumentTypeError):
CrcInteractive.parse_time('')

0 comments on commit 085dbc1

Please sign in to comment.