Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Anomaly Detection in Microservices Systems
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sashika sewwandi
Anomaly Detection in Microservices Systems
Commits
9b0f68a0
Commit
9b0f68a0
authored
Oct 10, 2022
by
sashika sewwandi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
75ec4dce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
Template.py
Template.py
+67
-0
No files found.
Template.py
0 → 100644
View file @
9b0f68a0
import
json
import
sys
import
boto3
from
boto3.s3.transfer
import
S3Transfer
from
abc
import
ABCMeta
class
Baseclass
(
metaclass
=
ABCMeta
):
def
metadata_setup
(
self
,
cong_file
):
"""
Setup metadata for the application
:return: set of global variables
"""
try
:
f
=
open
(
f
"metadata/{cong_file}.json"
,
"r"
)
data
=
json
.
loads
(
f
.
read
())
self
.
output_file
=
data
[
"output_file"
]
# twitter configuration
if
'twitter'
in
cong_file
:
self
.
key_word
=
data
[
"key_word"
]
self
.
access_token
=
data
[
"access_token"
]
self
.
data_size
=
data
[
"data_size"
]
elif
'quotes'
in
cong_file
:
self
.
base_url
=
data
[
"base_url"
]
# snowflake configuration
self
.
Account
=
data
[
"snowflake"
][
"Account"
]
self
.
data_warehouse
=
data
[
"snowflake"
][
"data_warehouse"
]
self
.
username
=
data
[
"snowflake"
][
"username"
]
self
.
password
=
data
[
"snowflake"
][
"password"
]
self
.
role
=
data
[
"snowflake"
][
"role"
]
self
.
database
=
data
[
"snowflake"
][
"database"
]
self
.
schema
=
data
[
"snowflake"
][
"schema"
]
self
.
table_name
=
data
[
"snowflake"
][
"table_name"
]
# aws configuration
self
.
access_key
=
data
[
"aws"
][
"aws_access_key_id"
]
self
.
secret_key
=
data
[
"aws"
][
"aws_secret_access_key"
]
self
.
bucket
=
data
[
"aws"
][
"bucket"
]
except
Exception
as
e
:
print
(
e
)
sys
.
exit
(
-
1
)
else
:
print
(
"Metadata configuration success"
)
def
s3_data_transfer
(
self
,
file
):
"""
Extract files will be uploaded to aws bucket
:param file: file which needs to be uploaded
:return: No return values
"""
try
:
client
=
boto3
.
client
(
's3'
,
aws_access_key_id
=
self
.
access_key
,
aws_secret_access_key
=
self
.
secret_key
,
)
s3
=
boto3
.
resource
(
's3'
)
transfer
=
S3Transfer
(
client
)
transfer
.
upload_file
(
file
,
self
.
bucket
,
file
)
except
Exception
as
e
:
print
(
e
)
sys
.
exit
(
-
1
)
else
:
print
(
"Data successfully load to s3 bucket"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment