def get_datasets_year(self, year=12, stream=None): datasets = {} periods = query.get_periods(self.client, year=year) hep_periods = [] for period in periods: if period.project.endswith('TeV'): hep_periods.append(period.name) runs = query.get_runs(self.client, hep_periods, year=year) n_runs = len(runs) for run_n, run in enumerate(runs): self.outstream.write( 'looking for {} of {} {}...'.format(run_n, n_runs, run)) try: ds = next(iter(self.ds_from_id(run, stream))) except DatasetMatchError as err: if err.matches: self.outstream.write('none in stream\n') self.bugstream.write(str(err) + '\n') continue else: self.outstream.write('nothing\n') self.bugstream.write(str(err) + '\n') continue self.outstream.write('found: {}\n'.format(ds.full_name)) datasets[ds.key] = ds return datasets
from pyAMI.client import AMIClient from pyAMI.query import get_runs, get_periods_for_run client = AMIClient() runs = get_runs(client, periods=["B", "K2"], year=11) print runs periods = get_periods_for_run(client, 201351) print periods