From 0aa36917296b1409b8a1110955fd2d977ded86b1 Mon Sep 17 00:00:00 2001 From: Maciej Wielgosz <maciej.wielgosz@nibio.no> Date: Wed, 25 Jan 2023 11:39:01 +0100 Subject: [PATCH] oracle wrapper - reading input from env vars --- run_oracle_wrapper.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/run_oracle_wrapper.py b/run_oracle_wrapper.py index b2b7f8a..3964a08 100644 --- a/run_oracle_wrapper.py +++ b/run_oracle_wrapper.py @@ -8,6 +8,7 @@ import sys import json import shutil import yaml +from urllib.parse import urlparse from pathlib import Path from oci.config import validate_config from oci.object_storage import ObjectStorageClient @@ -24,15 +25,24 @@ def run_oracle_wrapper(path_to_config_file): # create the client client = ObjectStorageClient(config) - # get the namespace - namespace = client.get_namespace().data - - # get the bucket name - bucket_name = 'bucket_lidar_data' - - # folder name inside the bucket - - input_folder_in_bucket = 'geoslam' + # read system environment variables + input_location = os.environ['OBJ_INPUT_LOCATION'] + + if input_location is not None: + print('Taking the input from the location ' + input_location) + parsed_url = urlparse(input_location) + input_folder_in_bucket = parsed_url.path[1:] + bucket_name = parsed_url.netloc.split('@')[0] + namespace = parsed_url.netloc.split('@')[1] + + else: + print('Taking the input from the default location') + # get the namespace + namespace = client.get_namespace().data + # get the bucket name + bucket_name = 'bucket_lidar_data' + # folder name inside the bucket + input_folder_in_bucket = 'geoslam' # read the config file from config folder with open(path_to_config_file) as f: -- GitLab