-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
104 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copies data from a v1 GraphQL api into a v2 database. | ||
import sqlalchemy as sa | ||
import contextlib | ||
import json | ||
import os | ||
from concurrent.futures import ProcessPoolExecutor, as_completed | ||
|
||
import click | ||
import cryoet_data_portal as cdp | ||
import requests | ||
from database import models | ||
from support.enums import tomogram_reconstruction_method_enum as reconstruction_enum | ||
|
||
from platformics.database.connect import init_sync_db | ||
|
||
|
||
@click.command() | ||
@click.argument("dataset_id", required=True, type=int) | ||
@click.option("--i-am-super-sure", help="this argument must be yes", type=str) | ||
@click.option("--db-uri", help="Database URI", type=str) | ||
def delete_dataset(dataset_id: int, i_am_super_sure: str, db_uri: str): | ||
if not db_uri: | ||
db_uri = ( | ||
f"postgresql+psycopg://{os.environ['PLATFORMICS_DATABASE_USER']}:{os.environ['PLATFORMICS_DATABASE_PASSWORD']}@{os.environ['PLATFORMICS_DATABASE_HOST']}:{os.environ['PLATFORMICS_DATABASE_PORT']}/{os.environ['PLATFORMICS_DATABASE_NAME']}", | ||
) | ||
|
||
print(f"DELETING DATASET {dataset_id}") | ||
if i_am_super_sure != "yes": | ||
print("You must specify '--i-am-super-sure yes' to delete a dataset") | ||
exit(1) | ||
db = init_sync_db(db_uri) | ||
with db.session() as session: | ||
obj = session.scalars(sa.select(models.Dataset).where(models.Dataset.id == dataset_id)).one() | ||
session.delete(obj) | ||
session.flush() | ||
session.commit() | ||
|
||
|
||
if __name__ == "__main__": | ||
delete_dataset() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters