@@ -154,6 +154,9 @@ def __init__(
154154 self .local_dataset_cache = local_dataset_cache
155155 self .force_renew = force_renew
156156 self .db_version = BaseRester ._get_database_version (self .endpoint )
157+ self .access_controlled_batch_ids = BaseRester ._get_access_restricted_batch_ids (
158+ self .endpoint
159+ )
157160
158161 if self .suffix :
159162 self .endpoint = urljoin (self .endpoint , self .suffix )
@@ -243,6 +246,25 @@ def _get_database_version(endpoint):
243246 """
244247 return requests .get (url = endpoint + "heartbeat" ).json ()["db_version" ]
245248
249+ @staticmethod
250+ @cache
251+ def _get_access_restricted_batch_ids (endpoint ):
252+ """Certain contributions to the Materials Project have access
253+ control restrictions that require explicit agreement to the
254+ Terms of Use for the respective datasets prior to access being
255+ granted.
256+
257+ A full list of the Terms of Use for all contributions in the
258+ Materials Project are available at:
259+
260+ https://next-gen.materialsproject.org/about/terms
261+
262+ Returns: a list of strings
263+ """
264+ return requests .get (url = endpoint + "heartbeat" ).json ()[
265+ "access_controlled_batch_ids"
266+ ]
267+
246268 def _post_resource (
247269 self ,
248270 body : dict | None = None ,
@@ -583,13 +605,10 @@ def _query_resource(
583605 builder .execute ("SELECT COUNT(*) FROM tbl" ).read_all ()
584606 )[0 ][0 ].as_py ()
585607
586- # TODO: Update tasks (+ others?) resource to have emmet-api BatchIdQuery operator
587- # -> need to modify BatchIdQuery operator to handle root level
588- # batch_id, not only builder_meta.batch_id
589- # if not has_gnome_access:
590- # num_docs_needed = self.count(
591- # {"batch_id_neq_any": SETTINGS.ACCESS_CONTROLLED_BATCH_IDS}
592- # )
608+ if not has_gnome_access :
609+ num_docs_needed = self .count (
610+ {"batch_id_neq_any" : self .access_controlled_batch_ids }
611+ )
593612
594613 pbar = (
595614 tqdm (
0 commit comments