from datasets import Dataset from huggingface_hub import HfApi, login import json # Initialize the dataset with a sample entry initial_data = { "model_id": ["example/model"], "revision": ["main"], "precision": ["fp16"], "security_score": [0.5], "safetensors_compliant": [True] } # Create a Dataset object dataset = Dataset.from_dict(initial_data) # Login to Hugging Face (you'll need to set the HUGGINGFACE_TOKEN environment variable) login() # Push the dataset to the Hugging Face Hub dataset.push_to_hub("stacklok/results") # Create a dataset card dataset_card = """ --- language: - en license: - mit --- # Dataset Card for stacklok/results This dataset contains evaluation results for various models, focusing on security scores and other relevant metrics. ## Dataset Structure The dataset contains the following fields: - `model_id`: The identifier of the model - `revision`: The revision or version of the model - `precision`: The precision used for the model (e.g., fp16, fp32) - `security_score`: A score representing the model's security evaluation - `safetensors_compliant`: A boolean indicating whether the model is compliant with safetensors ## Usage This dataset is used to populate the secure code leaderboard, providing insights into the security aspects of various models. """ # Write the dataset card with open("README.md", "w") as f: f.write(dataset_card) # Upload the dataset card api = HfApi() api.upload_file( path_or_fileobj="README.md", path_in_repo="README.md", repo_id="stacklok/results", repo_type="dataset" ) print("Dataset initialized and card uploaded successfully!")