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
cca432fa
Commit
cca432fa
authored
2 years ago
by
Maciej Wielgosz
Browse files
Options
Downloads
Patches
Plain Diff
update oracle run for multiple files reading
parent
361090fc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
run_oracle_wrapper.py
+28
-14
28 additions, 14 deletions
run_oracle_wrapper.py
with
28 additions
and
14 deletions
run_oracle_wrapper.py
+
28
−
14
View file @
cca432fa
...
...
@@ -30,30 +30,43 @@ def run_oracle_wrapper(path_to_config_file):
# get the bucket name
bucket_name
=
'
bucket_lidar_data
'
# get the object name
object_name
=
'
./geoslam/plot72_tile_-25_-25.las
'
# folder name inside the bucket
# get the object
file
=
client
.
get_object
(
namespace
,
bucket_name
,
object_name
)
input_folder_in_bucket
=
'
geoslam
'
# write the object to a file
with
open
(
'
plot_from_bucket.las
'
,
'
wb
'
)
as
f
:
for
chunk
in
file
.
data
.
raw
.
stream
(
1024
*
1024
,
decode_content
=
False
):
f
.
write
(
chunk
)
# read the config file from config folder
# read the config file from config folder
with
open
(
path_to_config_file
)
as
f
:
config_flow_params
=
yaml
.
load
(
f
,
Loader
=
yaml
.
FullLoader
)
# copy all files from the bucket to the input folder
# get the list of objects in the bucket
objects
=
client
.
list_objects
(
namespace
,
bucket_name
).
data
.
objects
# create the input folder if it does not exist
if
not
os
.
path
.
exists
(
config_flow_params
[
'
general
'
][
'
input_folder
'
]):
os
.
mkdir
(
config_flow_params
[
'
general
'
][
'
input_folder
'
])
# move the file to the input folder using shutil if it does not exist
if
not
os
.
path
.
exists
(
config_flow_params
[
'
general
'
][
'
input_folder
'
]
+
'
/plot_from_bucket.las
'
):
shutil
.
move
(
'
plot_from_bucket.las
'
,
config_flow_params
[
'
general
'
][
'
input_folder
'
])
# download the files from the bucket to the input folder
for
item
in
objects
:
if
item
.
name
.
split
(
'
/
'
)[
0
]
==
input_folder_in_bucket
:
if
not
(
item
.
name
.
split
(
'
/
'
)[
1
]
==
''
):
object_name
=
item
.
name
.
split
(
'
/
'
)[
1
]
print
(
'
Downloading the file
'
+
object_name
+
'
from the bucket
'
+
bucket_name
)
path_to_object
=
os
.
path
.
join
(
input_folder_in_bucket
,
object_name
)
# get the object
file
=
client
.
get_object
(
namespace
,
bucket_name
,
path_to_object
)
# write the object to a file
with
open
(
object_name
,
'
wb
'
)
as
f
:
for
chunk
in
file
.
data
.
raw
.
stream
(
1024
*
1024
,
decode_content
=
False
):
f
.
write
(
chunk
)
# check if the file already exists in the input folder and delete it if it does
if
os
.
path
.
exists
(
config_flow_params
[
'
general
'
][
'
input_folder
'
]
+
'
/
'
+
object_name
):
os
.
remove
(
config_flow_params
[
'
general
'
][
'
input_folder
'
]
+
'
/
'
+
object_name
)
# move the file to the input folder and overwrite if it already exists
shutil
.
move
(
object_name
,
config_flow_params
[
'
general
'
][
'
input_folder
'
])
from
run
import
main
...
...
@@ -81,5 +94,6 @@ if __name__ == '__main__':
args
=
parser
.
parse_args
()
# run the main function
print
(
'
Running the main function in run_oracle_wrapper.py
'
)
run_oracle_wrapper
(
args
.
path_to_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