You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
751 B
Python

import os.path as osp
from config import get_method, ASSETS_DIR
import json
annotations = {}
for obj in ['user', 'project', 'task', 'job', 'organization', 'membership',
'invitation']:
response = get_method('admin1', f'{obj}s', page_size='all')
with open(osp.join(ASSETS_DIR, f'{obj}s.json'), 'w') as f:
json.dump(response.json(), f, indent=2, sort_keys=True)
if obj == 'job':
annotations[obj] = {}
for job in response.json()['results']:
jid = job["id"]
response = get_method('admin1', f'jobs/{jid}/annotations')
annotations[obj][jid] = response.json()
with open(osp.join(ASSETS_DIR, f'annotations.json'), 'w') as f:
json.dump(annotations, f, indent=2, sort_keys=True)