def METHOD_NAME(
    sm_config, ds_id, ds_mask, ds_file, use_inactive_index, offline_reindex, update_fields
):
    assert ds_id or ds_mask or ds_file or offline_reindex
    IsocalcWrapper.set_centroids_cache_enabled(True)
    if offline_reindex:
        _reindex_all(sm_config)
    else:
        es_config = sm_config['elasticsearch']
        if use_inactive_index:
            es_config = get_inactive_dataset_index_es_config(es_config)
        db = DB()
        es_exp = ESExporter(db, sm_config={**sm_config, 'elasticsearch': es_config})
        if ds_id:
            ds_ids = ds_id.split(',')
        elif ds_mask:
            ds_ids = [
                id
                for (id,) in db.select(
                    "SELECT id FROM dataset WHERE name like '{}%' ORDER BY id".format(ds_mask)
                )
            ]
        elif ds_file:
            with ds_file as file:
                ds_ids = [line.strip() for line in file.readlines()]
        else:
            ds_ids = []
        if update_fields:
            _partial_update_datasets(ds_ids, es_exp, update_fields.split(','))
        else:
            _reindex_datasets(ds_ids, es_exp)