Skip to content

Commit

Permalink
Merge pull request #96 from HPCNow/main
Browse files Browse the repository at this point in the history
froster v0.14.9
  • Loading branch information
victormachadoperez authored Jun 26, 2024
2 parents b70eab1 + a2e6074 commit 00f5744
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 43 deletions.
58 changes: 16 additions & 42 deletions froster/froster.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,13 @@ def set_credentials(self, aws: 'AWSBoto'):
try:
log(f'\n*** SET CREDENTIALS ***\n')

# AWS DIR is the default credentials directory
aws_dir = os.path.join(self.home_dir, '.aws')
os.makedirs(aws_dir, exist_ok=True, mode=0o775)

# Get the default credentials directory from the config file
default_credentials_dir = self.__get_configuration_entry(
'CREDENTIALS', 'credentials_dir')

if not os.path.exists(default_credentials_dir):
default_credentials_dir = None
'CREDENTIALS', 'credentials_dir', fallback=aws_dir)

# Ask user to enter the path to a aws credentials directory
credentials_dir_question = [
Expand Down Expand Up @@ -910,12 +911,10 @@ def set_email(self):
try:
log(f'\n*** SET EMAIL ***\n')

default_email = self.__get_configuration_entry('USER', 'email')

# Ask the user for their email
email = inquirer.text(
message="Enter your email",
default=default_email,
default=self.__get_configuration_entry('USER', 'email'),
validate=self.__inquirer_check_email_format)

# Print for a new line when prompting
Expand Down Expand Up @@ -946,16 +945,10 @@ def set_endpoint(self):
elif self.provider == 'GCS':
endpoint = 'https://storage.googleapis.com'
else:
default_endpoint = self.__get_configuration_entry(
'S3', 'endpoint', fallback=None)

if default_endpoint == '':
default_endpoint = None

# Get the user answer
endpoint = inquirer.text(
message=f'Enter the {self.provider} endpoint',
default=default_endpoint,
default=self.__get_configuration_entry('S3', 'endpoint'),
validate=self.__inquirer_check_required)

# Ensure the endpoint starts with "https://" for IDrive
Expand Down Expand Up @@ -1003,16 +996,11 @@ def set_provider(self):
list_of_providers = PROVIDERS_LIST
list_of_providers.append('+ Create new provider')

default_provider = self.__get_configuration_entry(
'S3', 'provider', fallback='AWS')

if default_provider == '':
default_provider = None

# Get the user answer
provider = inquirer.list_input(
"Choose your s3 provider",
default=default_provider,
default=self.__get_configuration_entry(
'S3', 'provider', fallback='AWS'),
choices=list_of_providers)

if provider == '+ Create new provider':
Expand Down Expand Up @@ -1072,16 +1060,11 @@ def set_s3(self, aws: "AWSBoto"):
# Store aws s3 bucket in the config object
self.__set_configuration_entry('S3', 'bucket_name', s3_bucket)

default_archive_dir = self.__get_configuration_entry(
'S3', 'archive_dir', fallback='froster')

if default_archive_dir == '':
default_archive_dir = 'froster'

# Get user answer
archive_dir = inquirer.text(
message='Enter the directory name inside S3 bucket',
default=default_archive_dir,
default=self.__get_configuration_entry(
'S3', 'archive_dir', fallback='froster'),
validate=self.__inquirer_check_required)

# Print newline after this prompt
Expand All @@ -1093,9 +1076,6 @@ def set_s3(self, aws: "AWSBoto"):
default_storage_class = self.__get_configuration_entry(
'S3', 'storage_class', fallback='DEEP_ARCHIVE')

if default_storage_class == '':
default_storage_class = None

if self.provider == 'AWS':
storage_class = inquirer.list_input(
"Choose the AWS S3 storage class",
Expand Down Expand Up @@ -1166,18 +1146,12 @@ def set_shared(self):
# and check if we need to move cfg.archive_json_file_name and configuration to the shared directory
if is_shared:

default_shared_dir = self.__get_configuration_entry(
'SHARED', 'shared_dir', fallback=None)

if default_shared_dir == '':
default_shared_dir = None

# Ask user to enter the path to a shared config directory
# TODO: make this inquiring in shortchut mode once this PR is merged: https://github.com/magmax/python-inquirer/pull/543
shared_config_dir_question = [
inquirer.Path(
'shared_dir', message='Enter the path to a shared config directory',
default=default_shared_dir,
default=self.__get_configuration_entry('SHARED', 'shared_dir'),
validate=self.__inquirer_check_path_exists)
]

Expand Down Expand Up @@ -1352,14 +1326,14 @@ def set_slurm(self, args):
slurm_walltime_days = inquirer.text(
message=f"Set the Slurm --time (days) for froster jobs",
default=self.__get_configuration_entry(
'SLURM', 'slurm_walltime_days', fallback='7'),
'SLURM', 'slurm_walltime_days', is_int=True, fallback=7),
validate=self.__inquirer_check_is_number)

# Get user answer
slurm_walltime_hours = inquirer.text(
message=f"Set the Slurm --time (hours) for froster jobs",
default=self.__get_configuration_entry(
'SLURM', 'slurm_walltime_days', fallback='0'),
'SLURM', 'slurm_walltime_days', is_int=True, fallback=0),
validate=self.__inquirer_check_is_number)

se = Slurm(args, self)
Expand Down Expand Up @@ -1479,8 +1453,8 @@ def __init__(self, args: argparse.Namespace, cfg: ConfigManager, arch: "Archiver

if hasattr(cfg, 'profile') and hasattr(cfg, 'endpoint'):
self.set_session(profile_name=cfg.profile,
region=cfg.get_region(cfg.profile),
endopoint_url=cfg.endpoint)
region=cfg.get_region(cfg.profile),
endopoint_url=cfg.endpoint)

except Exception:
print_error()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "froster"
version = "0.14.7"
version = "0.14.9"
description = "Froster is a tool for easy data transfer between local file systems and AWS S3 storage."
authors = ["Victor Machado <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 00f5744

Please sign in to comment.