Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hrushikesh-s committed Jan 29, 2024
1 parent b8fff1e commit 2047c95
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions alab_management/scripts/cleanup_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,31 @@ def cleanup_lab(all_collections: bool = False, _force_i_know_its_dangerous: bool
from alab_management.sample_view.sample_view import SampleView
from alab_management.utils.data_objects import _GetMongoCollection

_GetMongoCollection.init()
config = AlabConfig()
task_count_new = _GetMongoCollection.client.get_database(config["general"]["name"]) \
.get_collection("tasks").count_documents({})
if all_collections:
if not _force_i_know_its_dangerous:
if user_confirmation is None:
user_confirmation = input(
f"Are you sure you want to remove the whole database? "
f"It will purge all of your data in {config['mongodb']['host']}, "
f"which cannot be recovered. [yN]: "
)
f"It will purge all of your data [{task_count_new} entries] in {config['mongodb']['host']}, "
f"which cannot be recovered. [y/n]: "
)
if user_confirmation != "y":
return False
if database_name is None:
database_name = input("Write the name of the database that you want to remove: ")
database_name = input(
f"Write the name of the database that you want to remove. "
f"If you want to remove the simulation database then type in "
f"{config['general']['name']}: ")

if sim_mode != AlabConfig().is_sim_mode() or database_name == "Alab":
print("Wrong name of database. Hence, not removed.")
return False
elif sim_mode == AlabConfig().is_sim_mode() and database_name != "Alab":
print("Removing database...........")
print(f"Removing database {config['general']['name']}")
_GetMongoCollection.init()
_GetMongoCollection.client.drop_database(database_name) # type: ignore
else:
Expand Down

0 comments on commit 2047c95

Please sign in to comment.