from pathlib import Path import pandas as pd import requests import json def infer_split(name): name = name.lower() if "train" in name: return "train" if "val" in name or "validation" in name: return "validation" if "test" in name: return "test" return "unspecified" repo = Path(".").resolve() xyz_dir = repo / "xyz" h5_dir = repo / "h5" rows = [] for xyz_file in sorted(xyz_dir.glob("*.xyz")): sample_id = xyz_file.stem h5_file = h5_dir / f"{sample_id}.h5" rows.append({ "id": sample_id, "xyz_path": str(xyz_file.relative_to(repo)), "h5_path": str(h5_file.relative_to(repo)) if h5_file.exists() else None, "split": infer_split(sample_id), }) df = pd.DataFrame(rows) print(df) print(f"Rows: {len(df)}") df.to_parquet("metadata.parquet", index=False) # --- Fetch Croissant metadata from Hugging Face --- url = "https://huggingface.co/api/datasets/CatalystAnonymous/catalyst_mxenes/croissant" response = requests.get(url) response.raise_for_status() data = response.json() # --- Get dataset node --- # Croissant can either be a single Dataset node or use @graph. if "@graph" in data: dataset_node = data["@graph"][0] else: dataset_node = data # --- Update general dataset description --- dataset_node["description"] = ( "Dataset associated with the article: Benchmark Dataset for Catalysis on 2D MXenes. " "The dataset contains computational catalyst data for MXene structures, including " "first-principles simulation results intended for machine learning benchmarks." ) # --- Inject Responsible AI metadata --- dataset_node["rai:dataLimitations"] = ( "The dataset is limited to adsorption on MXenes with a Ti$_2$C backbone, " "terminated by O and/or OH groups at varying surface coverages. " "The considered chemical reactions are restricted to those involving CO$_2$, H$_2$, H$_2$O, " "and HCOOH, including adsorbed reaction intermediates such as HCOO$^-$ and COOH$^-$. " ) dataset_node["rai:dataBiases"] = ( "The dataset reflects the sampling strategy, structural prototypes, adsorbate choices, " "simulation settings, and preprocessing choices used during construction. This may bias " "models toward the represented MXene compositions, surface configurations, and " "first-principles calculation conditions." ) dataset_node["rai:personalSensitiveInformation"] = ( "The dataset does not contain personal or sensitive information." ) dataset_node["rai:dataUseCases"] = ( "Intended for benchmarking and developing machine learning models for catalysis on " "2D MXenes, " "learning from first-principles simulation data." ) dataset_node["rai:dataSocialImpact"] = ( "The dataset may support catalyst discovery and materials science research. Misuse " "could include applying trained models outside the domain covered by the simulations " "or interpreting predictions as experimentally validated results." ) dataset_node["rai:hasSyntheticData"] = True # --- Save updated Croissant metadata --- with open("croissant.json", "w", encoding="utf-8") as f: json.dump(data, f, indent=2, ensure_ascii=False) print("Saved croissant.json with updated RAI metadata")