Created
April 24, 2024 20:00
-
-
Save allaway/279d2171b1a53c8f3aa0fb65772b86df to your computer and use it in GitHub Desktop.
ChatGPT-generated script to change portal data status based on data present (not tested yet)
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
import synapseclient | |
import pandas as pd | |
# Constants for the views | |
FILE_VIEW_ID = "syn16858331" | |
PROJECT_VIEW_ID = "syn52677631" | |
def main(): | |
syn = synapseclient.Synapse() | |
syn.login('YourUsername', 'YourPassword', rememberMe=True) | |
# Fetch the project view data | |
projects_df = syn.tableQuery(f'SELECT * FROM {PROJECT_VIEW_ID}').asDataFrame() | |
# Filter for projects with 'Data Pending' | |
pending_projects = projects_df[projects_df['dataStatus'] == 'Data Pending'] | |
# Fetch the file view data | |
fileview_df = syn.tableQuery(f'SELECT * FROM {FILE_VIEW_ID} WHERE contentType="file" AND resourceType LIKE "%experimentalData%"').asDataFrame() | |
# Iterate through pending projects | |
for idx, project in pending_projects.iterrows(): | |
# Check for associated experimental data files | |
related_files = fileview_df[fileview_df['projectId'] == project['id']] | |
if not related_files.empty: | |
# Update the project dataStatus to 'Under Embargo' | |
project['dataStatus'] = 'Under Embargo' | |
syn.store(synapseclient.Project(id=project['id'], annotations=project)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ChatGPT github action: