Datasets:
Upload folder using huggingface_hub
Browse filesFiles changed (5)
- .gitattributes+2
- README.md+51-18
- create_elaborated_metadata_table.pyAdded+197
- python_files_elaborated.txtAdded+3
- python_files_elaborated_metadata.csvAdded+3
57 unmodified lines58596057 unmodified lines*.mp4 filter=lfs diff=lfs merge=lfs -text*.webm filter=lfs diff=lfs merge=lfs -textmega_licensed_corpus_redacted.txt filter=lfs diff=lfs merge=lfs -text57 unmodified lines585960616257 unmodified lines*.mp4 filter=lfs diff=lfs merge=lfs -text*.webm filter=lfs diff=lfs merge=lfs -textmega_licensed_corpus_redacted.txt filter=lfs diff=lfs merge=lfs -textpython_files_elaborated.txt filter=lfs diff=lfs merge=lfs -textpython_files_elaborated_metadata.csv filter=lfs diff=lfs merge=lfs -text
10 unmodified lines11121314151617181920212223242526272829303132333435363738394041423 unmodified lines464748495051525310 unmodified lines64656667686910 unmodified linestags:- code- python- code-generationsize_categories:- 100K<n⩽1Mtask_categories:- text-generationtask_ids:- code-completion---# GitHub-PythonA **767 MB** corpus of permissively-licensed Python code drawn from public GitHub repositories.The dataset was created to support training and evaluation of **code-completion / generation** models.## Dataset at a glance| | Value || ---------------- | --------------------------------------------- || Files | 53,017 `.py` files || Repositories | 16,447 || Owners | 12,515 || Compressed size | 732 MB (`mega_licensed_corpus_redacted.txt`) || Vocabulary | 443,431 tokens (`custom_tokens_vocab.txt`) || Time period | Commits ≥ 2015-01-01 || License coverage | MIT, Apache-2.0, BSD, ISC, Unlicense || Removed secrets | ✅ – all hard-coded secrets/API keys redacted |Numbers were obtained from the final redacted corpus and companion metadata.3 unmodified lines```huggingface_dataset/├─ mega_licensed_corpus_redacted.txt # concatenated code corpus├─ python_files.txt # list of raw file URLs (1-per-line)└─ custom_tokens_vocab.txt # `<token>\t<id>` vocabulary file```10 unmodified lines---## Collection methodology1. **Repository discovery**10 unmodified lines1112131415161718192021222324252627282930313233343536373839404142434445464748495051523 unmodified lines5657585960616263646510 unmodified lines76777879808182838485868788899091929394959697989910010110210 unmodified linestags:- code- pythonsize_categories:- 100K<n⩽1Mtask_categories:- text-generation---# GitHub-Python — Licensed & Elaborated VariantsThis repository ships **two complementary Python-code corpora** extracted frompublic GitHub:- **Licensed Subset** – strictly _permissive-licensed_ files suitable forcommercial redistribution / model training (main corpus used in ourexperiments).- **Elaborated Collection** – a broader crawl that additionally contains filesunder _copyleft_ or unclear licenses (GPL/AGPL/LGPL, etc.). Useful foranalysis or pre-training where license mixing is acceptable.Both variants target **code-completion / generation** research.## Dataset at a glance| | **Licensed Subset** | **Elaborated Collection** || ------------------- | ------------------- | ------------------------- || Files (.py) | 53,017 | 186,066 || Unique repositories | 16,447 | 59,852 || Repository owners | 12,515 | 43,517 || Compressed size | 732 MB | 2.4 GB \* || Vocabulary (tokens) | 443,431 | 443,431 † || License coverage | Permissive only | Mixed (perm. + copyleft) || Secrets redacted | ✅ | ⚠️ not guaranteed || Time window | ≥ 2015-01-01 | ≥ 2015-01-01 |\* estimated – elaborated corpus is distributed as raw file list, not a singletext file.† same tokenizer file is shared by both variants.Numbers were obtained from the final redacted corpus and companion metadata.3 unmodified lines```huggingface_dataset/├─ mega_licensed_corpus_redacted.txt # Licensed Subset – concatenated code├─ python_files.txt # Licensed Subset – raw file URLs├─ python_files_elaborated.txt # Elaborated Collection – raw file URLs├─ python_files_elaborated_metadata.csv # Elaborated Collection metadata└─ custom_tokens_vocab.txt # `<token>\t<id>` vocabulary file```10 unmodified lines---## Dataset variants### 1. Licensed Subset (`mega_licensed_corpus_redacted.txt`)• 53 K permissively-licensed files (MIT/BSD/Apache/ISC/Unlicense).• All API keys & credentials removed.• Ready for redistribution & commercial use (respect upstream NOTICE files).### 2. Elaborated Collection (`python_files_elaborated.txt`)• 186 K files from a much larger crawl.• Contains **GPL / LGPL / AGPL and other copyleft** licenses.• Shipped _as URL list_ + metadata CSV; you must download the files yourself(`datasets.load_dataset` streaming, `wget`, etc.).• **No license filtering or secret-redaction performed** – use with caution.When first loading the dataset, decide which variant aligns with your use case(e.g. proprietary model training → Licensed Subset only).---## Collection methodology1. **Repository discovery**
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197#!/usr/bin/env python3"""Create metadata table for the elaborated GitHub Python dataset.
This script parses the python_files_elaborated.txt file containing GitHub URLsand extracts repository metadata (owner, repo name, file path).It generates a CSV file with this information and prints statistics.
The elaborated dataset contains more files than the licensed subset andmay include repositories with various licenses (not just permissive ones)."""
import csvimport osimport reimport pandas as pdfrom collections import Counter, defaultdictfrom tqdm import tqdmfrom urllib.parse import urlparse
# Input and output filesELABORATED_FILES_LIST = "python_files_elaborated.txt"LICENSED_FILES_LIST = "python_files.txt"OUTPUT_CSV = "python_files_elaborated_metadata.csv"
# Regular expression to parse GitHub raw URLs# Format: https://raw.githubusercontent.com/OWNER/REPO/BRANCH/PATHGITHUB_RAW_PATTERN = r"https://raw\.githubusercontent\.com/([^/]+)/([^/]+)/[^/]+/(.*)"
def parse_github_url(url): """ Parse a GitHub raw URL to extract owner, repo name, and file path. Args: url (str): GitHub raw URL Returns: tuple: (owner, repo_name, file_path) or None if URL doesn't match pattern """ match = re.match(GITHUB_RAW_PATTERN, url) if match: owner, repo_name, file_path = match.groups() return owner, repo_name, file_path return None
def create_metadata_table(file_list_path): """ Create a metadata table from a list of GitHub URLs. Args: file_list_path (str): Path to file containing GitHub URLs Returns: list: List of dictionaries with metadata """ metadata = [] # Read URLs from file with open(file_list_path, "r") as f: urls = [line.strip() for line in f if line.strip()] print(f"Processing URLs from {file_list_path}...") # Parse each URL and extract metadata for url in tqdm(urls, desc="Parsing URLs"): parsed = parse_github_url(url) if parsed: owner, repo_name, file_path = parsed metadata.append({ "owner": owner, "repo_name": repo_name, "file_path": file_path, "url": url }) return metadata
def generate_statistics(metadata, dataset_name): """ Generate and print statistics for the dataset. Args: metadata (list): List of dictionaries with metadata dataset_name (str): Name of the dataset for display """ # Count unique repositories and owners repos = set((item["owner"], item["repo_name"]) for item in metadata) owners = set(item["owner"] for item in metadata) # Count files by repository repo_counts = Counter((item["owner"], item["repo_name"]) for item in metadata) top_repos = repo_counts.most_common(10) # Count files by owner owner_counts = Counter(item["owner"] for item in metadata) top_owners = owner_counts.most_common(5) # Count file extensions extensions = Counter(os.path.splitext(item["file_path"])[1] for item in metadata) # Print statistics print(f"\n=== {dataset_name} Statistics ===") print(f"Total files: {len(metadata)}") print(f"Unique repositories: {len(repos)}") print(f"Unique repository owners: {len(owners)}") print("\nTop 10 repositories by file count:") for (owner, repo), count in top_repos: print(f" {owner}/{repo}: {count} files") print("\nFile extensions:") for ext, count in extensions.most_common(): if ext: # Skip empty extensions print(f" {ext}: {count} files") print("\nTop 5 repository owners:") for owner, count in top_owners: print(f" {owner}: {count} files") return { "total_files": len(metadata), "unique_repos": len(repos), "unique_owners": len(owners), "top_repos": top_repos, "top_owners": top_owners, "extensions": extensions }
def compare_datasets(elaborated_stats, licensed_stats): """ Compare statistics between elaborated and licensed datasets. Args: elaborated_stats (dict): Statistics for elaborated dataset licensed_stats (dict): Statistics for licensed dataset """ print("\n=== Dataset Comparison ===") print(f"Elaborated dataset: {elaborated_stats['total_files']} files") print(f"Licensed dataset: {licensed_stats['total_files']} files") print(f"Additional files in elaborated dataset: {elaborated_stats['total_files'] - licensed_stats['total_files']} files") # Calculate percentage increase pct_increase = ((elaborated_stats['total_files'] / licensed_stats['total_files']) - 1) * 100 print(f"Percentage increase: {pct_increase:.1f}%") # Compare repositories print(f"\nElaborated dataset: {elaborated_stats['unique_repos']} repositories") print(f"Licensed dataset: {licensed_stats['unique_repos']} repositories") # Compare owners print(f"\nElaborated dataset: {elaborated_stats['unique_owners']} repository owners") print(f"Licensed dataset: {licensed_stats['unique_owners']} repository owners") # Find repositories unique to elaborated dataset elaborated_repos = set((owner, repo) for (owner, repo), _ in elaborated_stats['top_repos']) licensed_repos = set((owner, repo) for (owner, repo), _ in licensed_stats['top_repos']) unique_to_elaborated = elaborated_repos - licensed_repos if unique_to_elaborated: print("\nTop repositories unique to elaborated dataset:") for owner, repo in list(unique_to_elaborated)[:5]: print(f" {owner}/{repo}")
def main(): # Process elaborated dataset elaborated_metadata = create_metadata_table(ELABORATED_FILES_LIST) # Save to CSV with open(OUTPUT_CSV, "w", newline="") as f: writer = csv.DictWriter(f, fieldnames=["owner", "repo_name", "file_path", "url"], quoting=csv.QUOTE_MINIMAL) writer.writeheader() writer.writerows(elaborated_metadata) print(f"Metadata saved to {OUTPUT_CSV}") # Generate statistics for elaborated dataset elaborated_stats = generate_statistics(elaborated_metadata, "Elaborated Dataset") # Process licensed dataset for comparison if os.path.exists(LICENSED_FILES_LIST): licensed_metadata = create_metadata_table(LICENSED_FILES_LIST) licensed_stats = generate_statistics(licensed_metadata, "Licensed Dataset") # Compare datasets compare_datasets(elaborated_stats, licensed_stats) else: print(f"Warning: {LICENSED_FILES_LIST} not found. Cannot compare datasets.")
if __name__ == "__main__": main()123version https://git-lfs.github.com/spec/v1oid sha256:b20e7f10e0a17de893f1a172abce460b41b937e3ea83e2c81f8773982db38578size 15102167123version https://git-lfs.github.com/spec/v1oid sha256:46359841e7cf01ebd2232ff24f310644481798ba85138db310dee8fb29417bbdsize 22895119.gitattributes+2
README.md+51-18
create_elaborated_metadata_table.pyAdded+197
python_files_elaborated.txtAdded+3
python_files_elaborated_metadata.csvAdded+3