-
Notifications
You must be signed in to change notification settings - Fork 9
Description
In the Airtable v1.2.1 I can click a tab like Variables , Experiments or MIPs and I see columns for each entry. I would like to be able to access this data via the python API. For instance for each experiment I am able request the minum of years to run this experiment (that's nice). For each MIP I can request its name, but not its longname (error) while longname is an attribute. For each experiment I can not request the MIP it belongs to (it does even not have MIP as attribute currently), but this is what I would appreciate (ok I made now manually a dictionary for that to circumvent, but that is maintenance unfriendly).
So it would be nice to be able to request via the python API:
-
Given an experiment, return the corresponding MIP
-
Given an experiment, return the (default) parent experiment
-
Given a MIP, return the list of experiments for this MIP
-
Given a MIP, return th elist of experiments of this MIP
-
In general: being able to reach all the metadata / attributes / info provided in the AIRtable given
a selected entity like: experiment, MIP, Physical Parameter, etc. Maybe all is a lot? But starting with the most frequent / handiest ones?
Or:
- Possibe to have a full dump of the AIRTables in a json or xml file
Below a short code which demonstrates the issue mentioned above:
#!/usr/bin/env python
# Based on the ../notebooks/HowTo-0*ipynb examples
from data_request_api.content import dump_transformation as dt
from data_request_api.query import data_request as dr
content_dic = dt.get_transformed_content()
DR = dr.DataRequest.from_separated_inputs(**content_dic)
# View attributes of a given Experiment
all_experiments = DR.get_experiments()
all_mips = DR.get_mips()
print('\n CMIP7 MIPs and attributes:')
nr_of_mips = 0
for mip in all_mips:
if nr_of_mips < 2: # Reducing the output for now
for k, v in mip.attributes.items():
print(' {:30} {}'.format(k, v))
print('\n')
nr_of_mips = nr_of_mips + 1
for mip in all_mips:
print(' {:14} '.format(str(mip.attributes['name']) ))
#print(' {:14} {} {}'.format(str(mip.attributes['name']), mip.attributes['mip_long_name'], mip.attributes['mip_website'])) # DOES NOT WORK currently
print('\n CMIP7 experiment name minimum duration (year):')
for experiment in all_experiments:
print(' {:34} {:4} '.format(str(experiment.attributes['name']), experiment.attributes['size_(years,_minimum)'] ))
#print(' {:34} {:4} {}'.format(str(experiment.attributes['name']), experiment.attributes['size_(years,_minimum)'], experiment.attributes['MIP'])) # DOES NOT WORK currently
print('\n')