Skip to content

Commit ba47f19

Browse files
Merge pull request #58 from HPCNow/main
froster v0.12.14 - Tests improvements
2 parents 63d486f + 8aa6019 commit ba47f19

File tree

4 files changed

+228
-98
lines changed

4 files changed

+228
-98
lines changed
File renamed without changes.

Diff for: froster/froster.py

+25-30
Original file line numberDiff line numberDiff line change
@@ -471,15 +471,14 @@ def set_aws(self, aws: 'AWSBoto'):
471471

472472
# Ask user to enter the path to a aws credentials directory
473473

474-
if os.path.exists(os.path.join(self.home_dir, '.aws')):
475-
default_aws_dir = os.path.join(self.home_dir, '.aws')
476-
else:
477-
default_aws_dir = None
474+
default_aws_dir = os.path.join(self.home_dir, '.aws')
475+
if not os.path.exists(os.path.join(self.home_dir, '.aws')):
476+
os.makedirs(self.aws_dir, exist_ok=True, mode=0o775)
478477

479478
aws_dir_question = [
480479
inquirer.Path(
481480
'aws_dir',
482-
message=f'Enter the path to aws credentials directory (default: {default_aws_dir})',
481+
message=f'Enter the path to aws credentials directory (default: ~/.aws)',
483482
default=default_aws_dir,
484483
validate=self.__inquirer_check_path_exists)
485484
]
@@ -660,9 +659,6 @@ def __set_aws_config(self, aws_profile_name, region):
660659
if not region:
661660
raise ValueError('No region provided')
662661

663-
# If it does not exist, create aws directory
664-
os.makedirs(self.aws_dir, exist_ok=True, mode=0o775)
665-
666662
# Create a aws config ConfigParser object
667663
aws_config = configparser.ConfigParser()
668664

@@ -706,9 +702,6 @@ def __set_aws_credentials(self,
706702
if not aws_secret_access_key:
707703
raise ValueError('No AWS secret access key provided')
708704

709-
# If it does not exist, create aws directory
710-
os.makedirs(self.aws_dir, exist_ok=True, mode=0o775)
711-
712705
# Create a aws credentials ConfigParser object
713706
aws_credentials = configparser.ConfigParser()
714707

@@ -1118,19 +1111,22 @@ def set_slurm(self, args):
11181111
'''Set the Slurm configuration'''
11191112

11201113
try:
1121-
# Run the sacctmgr command
1122-
result = subprocess.run(
1123-
['sacctmgr', 'show', 'config'], capture_output=False)
1124-
1125-
if result.returncode != 0:
1126-
print(
1127-
"sacctmgr command failed. Please ensure it's installed and in your PATH and you are in a head node.")
1128-
return False
11291114

11301115
if shutil.which('scontrol'):
11311116

11321117
print(f'\n*** SLURM CONFIGURATION ***\n')
11331118

1119+
# Run the sacctmgr command
1120+
result = subprocess.run(
1121+
['sacctmgr', 'show', 'config'], capture_output=True)
1122+
1123+
if result.returncode != 0:
1124+
print(
1125+
"\nError: sacctmgr command failed. Please ensure it's installed and in your PATH and you are in a head node.")
1126+
print(f'\n stdout: {result.stdout.decode("utf-8")}\n')
1127+
print(f'\n stderr: {result.stderr.decode("utf-8")}\n')
1128+
return False
1129+
11341130
slurm_walltime_days = inquirer.text(
11351131
message="Set the Slurm --time (days) for froster jobs (default = 7)",
11361132
default=7,
@@ -1141,12 +1137,11 @@ def set_slurm(self, args):
11411137
default=0,
11421138
validate=self.__inquirer_check_is_number)
11431139

1144-
# TODO: This class __init__ should not be here, it should be in the main
11451140
se = Slurm(args, self)
11461141

11471142
# Get the allowed partitions and QOS
11481143
parts = se.get_allowed_partitions_and_qos()
1149-
1144+
print (parts)
11501145
if parts is not None:
11511146
# Ask the user to select the Slurm partition and QOS
11521147
slurm_partition = inquirer.list_input(
@@ -6057,10 +6052,10 @@ def subcmd_config(self, cfg: ConfigManager, aws: AWSBoto):
60576052
if self.args.print:
60586053
return cfg.print_config()
60596054

6060-
if self.args.monitor:
6061-
froster_binary = os.path.join(cfg.bin_dir, 'froster')
6062-
return cfg.add_systemd_cron_job(
6063-
f'{froster_binary} restore --monitor', '30')
6055+
# if self.args.monitor:
6056+
# froster_binary = os.path.join(cfg.bin_dir, 'froster')
6057+
# return cfg.add_systemd_cron_job(
6058+
# f'{froster_binary} restore --monitor', '30')
60646059

60656060
print(f'\n*****************************')
60666061
print(f'*** FROSTER CONFIGURATION ***')
@@ -6086,7 +6081,7 @@ def subcmd_config(self, cfg: ConfigManager, aws: AWSBoto):
60866081

60876082
if not cfg.set_shared():
60886083
return False
6089-
6084+
60906085
# If shared configuration and shared_config.ini file exists, then use it
60916086
if cfg.is_shared:
60926087
if hasattr(cfg, 'shared_config_file') and os.path.exists(cfg.shared_config_file):
@@ -6215,10 +6210,10 @@ def subcmd_restore(self, arch: Archiver, aws: AWSBoto):
62156210
'Invalid credentials. Set new AWS credentials by running "froster config --aws"')
62166211
sys.exit(1)
62176212

6218-
if self.args.monitor:
6219-
# aws inactivity and cost monitoring
6220-
aws.monitor_ec2()
6221-
return
6213+
# if self.args.monitor:
6214+
# # aws inactivity and cost monitoring
6215+
# aws.monitor_ec2()
6216+
# return
62226217

62236218
if not self.args.folders:
62246219

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "froster"
7-
version = "0.12.12"
7+
version = "0.12.14"
88
description = "Froster is a tool for easy data transfer between local file systems and AWS S3 storage."
99
authors = ["Victor Machado <[email protected]>"]
1010
readme = "README.md"

0 commit comments

Comments
 (0)