schrodinger.application.fragment_virtual_screening.bq_query_task module¶
- schrodinger.application.fragment_virtual_screening.bq_query_task.read_args_yaml(bq_options)¶
Read BQ query parameters from yaml file bq_options, output dictionary yaml_args.
- schrodinger.application.fragment_virtual_screening.bq_query_task.download_blob(bucket_name, source_blob_name, destination_file_name)¶
Download a blob from the bucket.
The ID of your GCS bucket bucket_name = “your-bucket-name”
The ID of your GCS object source_blob_name = “storage-object-name”
The path to which the file should be downloaded destination_file_name = “local/path/to/file”
- schrodinger.application.fragment_virtual_screening.bq_query_task.read_query_cmd(queryfile)¶
Read query sql command file into a sql string.
- schrodinger.application.fragment_virtual_screening.bq_query_task.sanitize_dest_table_id(name)¶
Sanitize destination table name.
Replace all non-alphanumeric charactors with underscores, then add “_table” to its end. Input: name string Output: sanitized query destination table name
- schrodinger.application.fragment_virtual_screening.bq_query_task.get_query_job_config(dest_table_id, project_id, dataset_id)¶
Set up the query’s
QueryJobConfig
and return aQueryJobConfig
type var.
- schrodinger.application.fragment_virtual_screening.bq_query_task.set_table_expire(table_ref, client, days=5)¶
Set table to expire x (default = 5) days from the excution of this function.
- schrodinger.application.fragment_virtual_screening.bq_query_task.export_to_bucket(client, table_ref, csvprefix, bucket_name, bucket_folder)¶
Export table
table_ref
to a series of CSV files.Storage location:
gs://bucket_name/bucket_folder/
- schrodinger.application.fragment_virtual_screening.bq_query_task.download_exported_csv_from_bucket(csvprefix, n_csv, destination_dir, bucket_name, bucket_folder)¶
Download exported CSV files from the bucket to a local path.
- schrodinger.application.fragment_virtual_screening.bq_query_task.run_bq_query_task(queryfile, destination_dir, project_id, dataset_id, bucket_name, bucket_folder)¶
Run the entire BQ query task.
- Input: queryfile - query sql command file
destination_dir - location to store downloaded CSV files project_id - destination project ID for the query result table dataset_id - destination dataset ID for the query result table bucket_name - GCP bucket name for the csv files’ exporting destination bucket_folder - GCP bucket folder for the csv files’ exporting destination
Output: CSV file list
- schrodinger.application.fragment_virtual_screening.bq_query_task.try_access_bq_table(table_id, client)¶
Check if table with table_id exists.
table_id = “your-project.your_dataset.your_table”
- schrodinger.application.fragment_virtual_screening.bq_query_task.run_bq_query_task_restart(queryfile, destination_dir, project_id, dataset_id, bucket_name, bucket_folder)¶
Restart the entire BQ query task, skip the query if the table already exists.
(Because by default the table’s name is based on the query file name, finding an existing table doesn’t always mean it’s the one needed. e.g. a user changed the content of the query file but not its filename.)
- Input: queryfile - query sql command file
destination_dir - location to store downloaded CSV files project_id - destination project ID for the query result table dataset_id - destination dataset ID for the query result table bucket_name - GCP bucket name for the csv files’ exporting destination bucket_folder - GCP bucket folder for the csv files’ exporting destination
Output: CSV file list