Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
Utilites
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
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
harshavardhan.c
Utilites
Commits
47f8f6ba
Commit
47f8f6ba
authored
Sep 11, 2023
by
harshavardhan.c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
cleanup_script.py
cleanup_script.py
+49
-0
No files found.
cleanup_script.py
0 → 100644
View file @
47f8f6ba
import
pandas
as
pd
import
requests
from
pymongo
import
MongoClient
MONGO_URI
=
"MONGO_URI"
ilens_configuration
=
"ilens_configuration"
ilens_asset_model_details
=
"ilens_asset_model"
project_id
=
'PROJECT_ID'
project_prefix
=
True
public_uri
=
"PUBLIC_URI"
login_token
=
'LOGIN-TOKEN'
ilens_configuration
=
f
'{project_id}__{ilens_configuration}'
if
project_prefix
else
ilens_configuration
ilens_asset_model_details
=
f
'{project_id}__{ilens_asset_model_details}'
if
project_prefix
else
ilens_asset_model_details
excel_file
=
'cdc tags.xlsx'
sheet_name
=
'Tags Info'
df
=
pd
.
read_excel
(
excel_file
,
sheet_name
=
sheet_name
)
split_data
=
df
[
'Tag ID'
]
.
str
.
split
(
'$'
,
expand
=
True
)
last_positions
=
split_data
.
iloc
[:,
-
1
]
df
[
'tag_ids'
]
=
last_positions
tag_ids
=
df
[
'tag_ids'
]
.
unique
()
print
(
f
'{tag_ids} - {len(tag_ids)}'
)
connection
=
MongoClient
(
MONGO_URI
)
ilens_db
=
connection
[
ilens_configuration
]
tags
=
ilens_db
[
"tags"
]
tag_hierarchy
=
ilens_db
[
"tag_hierarchy"
]
print
(
"Deleting Parameters Information............."
)
tags
.
delete_many
({
"id"
:
{
"$nin"
:
tag_ids
}})
tag_hierarchy
.
delete_many
({
"parameter_id"
:
{
"$nin"
:
tag_ids
}})
print
(
"Deleting Asset Model Information............."
)
ilens_asset_model
=
connection
[
ilens_asset_model_details
]
asset_model_details
=
ilens_asset_model
[
"asset_model_details"
]
query
=
{
'asset_model_name'
:
{
'$not'
:
{
'$regex'
:
"test"
,
'$options'
:
'i'
}}}
asset_model_info
=
asset_model_details
.
find
(
query
,
{
"_id"
:
0
,
"asset_model_id"
:
1
,
"asset_version"
:
1
,
"asset_model_name"
:
1
})
request_uri
=
f
"{public_uri}/scada_dt/asset/asset_model_delete"
input_payload
=
{
"project_id"
:
project_id
,
"asset_model_id"
:
"asset_model_101"
,
"asset_version"
:
"1.0"
}
for
each
in
asset_model_info
:
input_payload
[
'asset_model_id'
]
=
each
[
'asset_model_id'
]
input_payload
[
'asset_version'
]
=
each
[
'asset_version'
]
print
(
f
"Deleting Asset Model Information for {input_payload}............."
)
response
=
requests
.
post
(
request_uri
,
json
=
input_payload
,
cookies
=
{
'login-token'
:
login_token
,
'projectId'
:
project_id
})
print
(
response
.
json
())
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