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

Resolve input paths for compression before passing them to the container #49

Merged
merged 1 commit into from
Feb 12, 2022
Merged
Changes from all commits
Commits
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
19 changes: 15 additions & 4 deletions components/package-template/src/sbin/compress
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import sys
# Setup logging
# Create logger
log = logging.getLogger('clp')
log.setLevel(logging.DEBUG)
log.setLevel(logging.INFO)
# Setup console logging
logging_console_handler = logging.StreamHandler()
logging_formatter = logging.Formatter('%(asctime)s [%(levelname)s] [%(name)s] %(message)s')
Expand Down Expand Up @@ -93,10 +93,9 @@ def main(argv):
try:
check_env(clp_cluster_name)
except EnvironmentError as ex:
logging.error(ex)
log.error(ex)
return -1

# TODO: check path and perform path conversion
docker_exec_cmd = [
'docker', 'exec',
'--workdir', f'{CONTAINER_CLP_INSTALL_PREFIX}/clp',
Expand All @@ -105,11 +104,23 @@ def main(argv):
'sbin/native/compress', '--config', f'{CONTAINER_CLP_INSTALL_PREFIX}/.{clp_package_config.cluster_name}.yaml'
]
for path in parsed_args.paths:
path = str(pathlib.Path(path).resolve())
docker_exec_cmd.append(path)
if parsed_args.input_list is not None:
# Validate all paths in input list
all_paths_valid = True
with open(parsed_args.input_list, 'r') as f:
for line in f:
path = pathlib.Path(line.rstrip())
if not path.is_absolute():
log.error(f'Invalid relative path in input list: {path}')
all_paths_valid = False
if not all_paths_valid:
raise ValueError("--input-list must only contain absolute paths")

docker_exec_cmd.append('--input-list')
docker_exec_cmd.append(parsed_args.input_list)
logging.info(docker_exec_cmd)
log.debug(docker_exec_cmd)
subprocess.run(docker_exec_cmd)

return 0
Expand Down