Skip to content

Commit

Permalink
Python script to read production search index
Browse files Browse the repository at this point in the history
  • Loading branch information
BenGalewsky committed Dec 22, 2023
1 parent f16dd81 commit 62dd9ff
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/.mdfsecrets.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"smtp_hostname": "email-smtp.us-east-1.amazonaws.com",
"smtp_user": "AKIAYDM4GMMT2VHWEP6A",
"smtp_pass": "BO/JNfw92A1e9YAGk10MSp1Q6Zs0WmBzWJbrHlSAYuSM",
"API_CLIENT_ID": "4d5f8e8b-a61d-40d8-bb58-5a3f5d1d200a",
"API_CLIENT_SECRET": "9ZPvyAWasU76P6nx8tGbcCToSS3z8MKrL+FEM/IcL4E="
}
41 changes: 41 additions & 0 deletions scripts/convert_index1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import json
import os
import sys

import globus_sdk

if "API_CLIENT_ID" in os.environ:
globus_secrets = {
"API_CLIENT_ID": os.environ["API_CLIENT_ID"],
"API_CLIENT_SECRET": os.environ["API_CLIENT_SECRET"],
"smtp_hostname": os.environ["SMTP_HOSTNAME"],
"smtp_user": os.environ["SMTP_USER"],
"smtp_pass": os.environ["SMTP_PASS"]
}
else:
if len(sys.argv) == 2:
secret_file = f"./.mdfsecrets.{sys.argv[1]}"
else:
secret_file = "./.mdfsecrets"

with open(secret_file, 'r') as f:
globus_secrets = json.load(f)

index = "1a57bbe5-5272-477f-9d31-343b8258b7a5"


client = globus_sdk.ConfidentialAppAuthClient(globus_secrets['API_CLIENT_ID'], globus_secrets['API_CLIENT_SECRET'])
cc_authorizer = globus_sdk.ClientCredentialsAuthorizer(client, globus_sdk.SearchClient.scopes.all)

search_client = globus_sdk.SearchClient(authorizer=cc_authorizer)

processed = 0

for page in search_client.paginated.search(index, "*"):
for result in page.data["gmeta"]:
print(f"{result['subject']}: {len(result['entries'])}")
processed += 1

print(processed)
if processed > 20:
break

0 comments on commit 62dd9ff

Please sign in to comment.