Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
instance_segmentation_classic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maciej Wielgosz
instance_segmentation_classic
Commits
4fe33e0c
Commit
4fe33e0c
authored
2 years ago
by
Maciej Wielgosz
Browse files
Options
Downloads
Patches
Plain Diff
oracle wrapper - reading input and outputs from env vars
parent
0aa36917
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
run_bash_scripts/tls.sh
+1
-1
1 addition, 1 deletion
run_bash_scripts/tls.sh
run_oracle_wrapper.py
+28
-9
28 additions, 9 deletions
run_oracle_wrapper.py
with
29 additions
and
10 deletions
run_bash_scripts/tls.sh
+
1
−
1
View file @
4fe33e0c
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
############################ parameters #################################################
############################ parameters #################################################
# General parameters
# General parameters
CLEAR_INPUT_FOLDER
=
1
# 1: clear input folder, 0: not clear input folder
CLEAR_INPUT_FOLDER
=
1
# 1: clear input folder, 0: not clear input folder
CONDA_ENV
=
"pdal-env
-1
"
# conda environment for running the pipeline
CONDA_ENV
=
"pdal-env"
# conda environment for running the pipeline
# Tiling parameters
# Tiling parameters
data_folder
=
""
# path to the folder containing the data
data_folder
=
""
# path to the folder containing the data
...
...
This diff is collapsed.
Click to expand it.
run_oracle_wrapper.py
+
28
−
9
View file @
4fe33e0c
...
@@ -27,30 +27,49 @@ def run_oracle_wrapper(path_to_config_file):
...
@@ -27,30 +27,49 @@ def run_oracle_wrapper(path_to_config_file):
# read system environment variables
# read system environment variables
input_location
=
os
.
environ
[
'
OBJ_INPUT_LOCATION
'
]
input_location
=
os
.
environ
[
'
OBJ_INPUT_LOCATION
'
]
output_location
=
os
.
environ
[
'
OBJ_OUTPUT_LOCATION
'
]
# doing for the input
if
input_location
is
not
None
:
if
input_location
is
not
None
:
print
(
'
Taking the input from the location
'
+
input_location
)
print
(
'
Taking the input from the location
'
+
input_location
)
parsed_url
=
urlparse
(
input_location
)
parsed_url
=
urlparse
(
input_location
)
input_folder_in_bucket
=
parsed_url
.
path
[
1
:]
input_folder_in_bucket
=
parsed_url
.
path
[
1
:]
bucket_name
=
parsed_url
.
netloc
.
split
(
'
@
'
)[
0
]
input_
bucket_name
=
parsed_url
.
netloc
.
split
(
'
@
'
)[
0
]
namespace
=
parsed_url
.
netloc
.
split
(
'
@
'
)[
1
]
input_
namespace
=
parsed_url
.
netloc
.
split
(
'
@
'
)[
1
]
else
:
else
:
print
(
'
Taking the input from the default location
'
)
print
(
'
Taking the input from the default location
'
)
# get the namespace
# get the
input_
namespace
namespace
=
client
.
get_namespace
().
data
input_
namespace
=
client
.
get_
input_
namespace
().
data
# get the bucket name
# get the bucket name
bucket_name
=
'
bucket_lidar_data
'
input_
bucket_name
=
'
bucket_lidar_data
'
# folder name inside the bucket
# folder name inside the bucket
input_folder_in_bucket
=
'
geoslam
'
input_folder_in_bucket
=
'
geoslam
'
# doing for the output
if
output_location
is
not
None
:
print
(
'
Saving the output to the location
'
+
output_location
)
parsed_url
=
urlparse
(
output_location
)
output_folder_in_bucket
=
parsed_url
.
path
[
1
:]
output_bucket_name
=
parsed_url
.
netloc
.
split
(
'
@
'
)[
0
]
output_namespace
=
parsed_url
.
netloc
.
split
(
'
@
'
)[
1
]
else
:
print
(
'
Saving the output to the default location
'
)
# get the output_namespace
output_namespace
=
client
.
get_input_namespace
().
data
# get the bucket name
output_bucket_name
=
'
bucket_lidar_data
'
# folder name inside the bucket
output_folder_in_bucket
=
'
output
'
# read the config file from config folder
# read the config file from config folder
with
open
(
path_to_config_file
)
as
f
:
with
open
(
path_to_config_file
)
as
f
:
config_flow_params
=
yaml
.
load
(
f
,
Loader
=
yaml
.
FullLoader
)
config_flow_params
=
yaml
.
load
(
f
,
Loader
=
yaml
.
FullLoader
)
# copy all files from the bucket to the input folder
# copy all files from the bucket to the input folder
# get the list of objects in the bucket
# get the list of objects in the bucket
objects
=
client
.
list_objects
(
namespace
,
bucket_name
).
data
.
objects
objects
=
client
.
list_objects
(
input_
namespace
,
input_
bucket_name
).
data
.
objects
# create the input folder if it does not exist
# create the input folder if it does not exist
if
not
os
.
path
.
exists
(
config_flow_params
[
'
general
'
][
'
input_folder
'
]):
if
not
os
.
path
.
exists
(
config_flow_params
[
'
general
'
][
'
input_folder
'
]):
...
@@ -62,10 +81,10 @@ def run_oracle_wrapper(path_to_config_file):
...
@@ -62,10 +81,10 @@ def run_oracle_wrapper(path_to_config_file):
if
not
(
item
.
name
.
split
(
'
/
'
)[
1
]
==
''
):
if
not
(
item
.
name
.
split
(
'
/
'
)[
1
]
==
''
):
object_name
=
item
.
name
.
split
(
'
/
'
)[
1
]
object_name
=
item
.
name
.
split
(
'
/
'
)[
1
]
print
(
'
Downloading the file
'
+
object_name
+
'
from the bucket
'
+
bucket_name
)
print
(
'
Downloading the file
'
+
object_name
+
'
from the bucket
'
+
input_
bucket_name
)
path_to_object
=
os
.
path
.
join
(
input_folder_in_bucket
,
object_name
)
path_to_object
=
os
.
path
.
join
(
input_folder_in_bucket
,
object_name
)
# get the object
# get the object
file
=
client
.
get_object
(
namespace
,
bucket_name
,
path_to_object
)
file
=
client
.
get_object
(
input_
namespace
,
input_
bucket_name
,
path_to_object
)
# write the object to a file
# write the object to a file
with
open
(
object_name
,
'
wb
'
)
as
f
:
with
open
(
object_name
,
'
wb
'
)
as
f
:
...
@@ -95,7 +114,7 @@ def run_oracle_wrapper(path_to_config_file):
...
@@ -95,7 +114,7 @@ def run_oracle_wrapper(path_to_config_file):
file_name
=
file
file_name
=
file
# upload the file to the bucket
# upload the file to the bucket
client
.
put_object
(
namespace
,
bucket_name
,
'
output/
'
+
file_name
,
io
.
open
(
path_to_file
,
'
rb
'
))
client
.
put_object
(
output_
namespace
,
output_
bucket_name
,
os
.
path
.
join
(
output_folder_in_bucket
,
file_name
)
,
io
.
open
(
path_to_file
,
'
rb
'
))
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
# use argparse to get the path to the config file
# use argparse to get the path to the config file
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment