greenmining 1.0.6__py3-none-any.whl → 1.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
greenmining/__init__.py CHANGED
@@ -9,7 +9,7 @@ from greenmining.gsf_patterns import (
9
9
  is_green_aware,
10
10
  )
11
11
 
12
- __version__ = "1.0.6"
12
+ __version__ = "1.0.7"
13
13
 
14
14
 
15
15
  def fetch_repositories(
@@ -18,6 +18,10 @@ def fetch_repositories(
18
18
  min_stars: int = None,
19
19
  languages: list = None,
20
20
  keywords: str = None,
21
+ created_after: str = None,
22
+ created_before: str = None,
23
+ pushed_after: str = None,
24
+ pushed_before: str = None,
21
25
  ):
22
26
  # Fetch repositories from GitHub with custom search keywords.
23
27
  config = Config()
@@ -29,6 +33,10 @@ def fetch_repositories(
29
33
  min_stars=min_stars,
30
34
  languages=languages,
31
35
  keywords=keywords,
36
+ created_after=created_after,
37
+ created_before=created_before,
38
+ pushed_after=pushed_after,
39
+ pushed_before=pushed_before,
32
40
  )
33
41
 
34
42
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: greenmining
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: An empirical Python library for Mining Software Repositories (MSR) in Green IT research
5
5
  Author-email: Adam Bouafia <a.bouafia@student.vu.nl>
6
6
  License: MIT
@@ -330,7 +330,137 @@ print(f"Top patterns: {stats['top_patterns'][:5]}")
330
330
  aggregator.export_to_csv(results, "output.csv")
331
331
  ```
332
332
 
333
- #### Batch Analysis
333
+ #### URL-Based Repository Analysis
334
+
335
+ ```python
336
+ from greenmining.services.local_repo_analyzer import LocalRepoAnalyzer
337
+
338
+ analyzer = LocalRepoAnalyzer(
339
+ max_commits=200,
340
+ cleanup_after=True,
341
+ )
342
+
343
+ result = analyzer.analyze_repository("https://github.com/pallets/flask")
344
+
345
+ print(f"Repository: {result.name}")
346
+ print(f"Commits analyzed: {result.total_commits}")
347
+ print(f"Green-aware: {result.green_commits} ({result.green_commit_rate:.1%})")
348
+
349
+ for commit in result.commits[:5]:
350
+ if commit.green_aware:
351
+ print(f" {commit.message[:60]}...")
352
+ ```
353
+
354
+ #### Batch Analysis with Parallelism
355
+
356
+ ```python
357
+ from greenmining import analyze_repositories
358
+
359
+ results = analyze_repositories(
360
+ urls=[
361
+ "https://github.com/kubernetes/kubernetes",
362
+ "https://github.com/istio/istio",
363
+ "https://github.com/envoyproxy/envoy",
364
+ ],
365
+ max_commits=100,
366
+ parallel_workers=3,
367
+ energy_tracking=True,
368
+ energy_backend="auto",
369
+ )
370
+
371
+ for result in results:
372
+ print(f"{result.name}: {result.green_commit_rate:.1%} green")
373
+ ```
374
+
375
+ #### Private Repository Analysis
376
+
377
+ ```python
378
+ from greenmining.services.local_repo_analyzer import LocalRepoAnalyzer
379
+
380
+ # HTTPS with token
381
+ analyzer = LocalRepoAnalyzer(github_token="ghp_xxxx")
382
+ result = analyzer.analyze_repository("https://github.com/company/private-repo")
383
+
384
+ # SSH with key
385
+ analyzer = LocalRepoAnalyzer(ssh_key_path="~/.ssh/id_rsa")
386
+ result = analyzer.analyze_repository("git@github.com:company/private-repo.git")
387
+ ```
388
+
389
+ #### Power Regression Detection
390
+
391
+ ```python
392
+ from greenmining.analyzers import PowerRegressionDetector
393
+
394
+ detector = PowerRegressionDetector(
395
+ test_command="pytest tests/ -x",
396
+ energy_backend="rapl",
397
+ threshold_percent=5.0,
398
+ iterations=5,
399
+ )
400
+
401
+ regressions = detector.detect(
402
+ repo_path="/path/to/repo",
403
+ baseline_commit="v1.0.0",
404
+ target_commit="HEAD",
405
+ )
406
+
407
+ for regression in regressions:
408
+ print(f"Commit {regression.sha[:8]}: +{regression.power_increase:.1f}%")
409
+ ```
410
+
411
+ #### Version Power Comparison
412
+
413
+ ```python
414
+ from greenmining.analyzers import VersionPowerAnalyzer
415
+
416
+ analyzer = VersionPowerAnalyzer(
417
+ test_command="pytest tests/",
418
+ energy_backend="rapl",
419
+ iterations=10,
420
+ warmup_iterations=2,
421
+ )
422
+
423
+ report = analyzer.analyze_versions(
424
+ repo_path="/path/to/repo",
425
+ versions=["v1.0", "v1.1", "v1.2", "v2.0"],
426
+ )
427
+
428
+ print(report.summary())
429
+ print(f"Trend: {report.trend}")
430
+ print(f"Most efficient: {report.most_efficient}")
431
+ ```
432
+
433
+ #### Metrics-to-Power Correlation
434
+
435
+ ```python
436
+ from greenmining.analyzers import MetricsPowerCorrelator
437
+
438
+ correlator = MetricsPowerCorrelator()
439
+ correlator.fit(
440
+ metrics=["complexity", "nloc", "code_churn"],
441
+ metrics_values={
442
+ "complexity": [10, 20, 30, 40],
443
+ "nloc": [100, 200, 300, 400],
444
+ "code_churn": [50, 100, 150, 200],
445
+ },
446
+ power_measurements=[5.0, 8.0, 12.0, 15.0],
447
+ )
448
+
449
+ print(f"Pearson: {correlator.pearson}")
450
+ print(f"Spearman: {correlator.spearman}")
451
+ print(f"Feature importance: {correlator.feature_importance}")
452
+ ```
453
+
454
+ #### Web Dashboard
455
+
456
+ ```python
457
+ from greenmining.dashboard import run_dashboard
458
+
459
+ # Launch interactive dashboard (requires pip install greenmining[dashboard])
460
+ run_dashboard(data_dir="./data", host="127.0.0.1", port=5000)
461
+ ```
462
+
463
+ #### Pipeline Batch Analysis
334
464
 
335
465
  ```python
336
466
  from greenmining.controllers.repository_controller import RepositoryController
@@ -551,17 +681,24 @@ config = Config(
551
681
 
552
682
  ### Core Capabilities
553
683
 
554
- - **Pattern Detection**: Automatically identifies 122 sustainability patterns across 15 categories
555
- - **Keyword Analysis**: Scans commit messages using 321 green software keywords
556
- - **Custom Repository Fetching**: Fetch repositories with custom search keywords (not limited to microservices)
557
- - **Repository Analysis**: Analyzes repositories from GitHub with flexible filtering
558
- - **Batch Processing**: Analyze hundreds of repositories and thousands of commits
559
- - **Multi-format Output**: Generates Markdown reports, CSV exports, and JSON data
560
- - **Statistical Analysis**: Calculates green-awareness metrics, pattern distribution, and trends
684
+ - **Pattern Detection**: 122 sustainability patterns across 15 categories from the GSF catalog
685
+ - **Keyword Analysis**: 321 green software detection keywords
686
+ - **Repository Fetching**: GraphQL API with date, star, and language filters
687
+ - **URL-Based Analysis**: Direct PyDriller analysis from GitHub URLs (HTTPS and SSH)
688
+ - **Batch Processing**: Parallel analysis of multiple repositories with configurable workers
689
+ - **Private Repository Support**: Authentication via SSH keys or GitHub tokens
690
+ - **Energy Measurement**: RAPL, CodeCarbon, and CPU Energy Meter backends
691
+ - **Carbon Footprint Reporting**: CO2 emissions with 20+ country profiles and cloud region support (AWS, GCP, Azure)
692
+ - **Power Regression Detection**: Identify commits that increased energy consumption
693
+ - **Metrics-to-Power Correlation**: Pearson and Spearman analysis between code metrics and power
694
+ - **Version Power Comparison**: Compare power consumption across software versions with trend detection
695
+ - **Method-Level Analysis**: Per-method complexity metrics via Lizard integration
696
+ - **Source Code Access**: Before/after source code for refactoring detection
697
+ - **Full Process Metrics**: All 8 PyDriller process metrics (ChangeSet, CodeChurn, CommitsCount, ContributorsCount, ContributorsExperience, HistoryComplexity, HunksCount, LinesCount)
698
+ - **Statistical Analysis**: Correlations, effect sizes, and temporal trends
699
+ - **Multi-format Output**: Markdown reports, CSV exports, JSON data
700
+ - **Web Dashboard**: Flask-based interactive visualization (`pip install greenmining[dashboard]`)
561
701
  - **Docker Support**: Pre-built images for containerized analysis
562
- - **Programmatic API**: Full Python API for custom workflows and integrations
563
- - **Clean Architecture**: Modular design with services layer (Fetcher, Extractor, Analyzer, Aggregator, Reports)
564
- - **Energy Measurement**: Real-time energy consumption tracking via RAPL (Linux) or CodeCarbon (cross-platform)
565
702
 
566
703
  ### Energy Measurement
567
704
 
@@ -712,8 +849,15 @@ ruff check greenmining/ tests/
712
849
  - Python 3.9+
713
850
  - PyGithub >= 2.1.1
714
851
  - PyDriller >= 2.5
715
- - pandas >= 2.2.0
716
- - codecarbon >= 2.0.0 (optional, for cross-platform energy measurement)
852
+ - pandas >= 2.2.0
853
+
854
+ **Optional dependencies:**
855
+
856
+ ```bash
857
+ pip install greenmining[energy] # psutil, codecarbon (energy measurement)
858
+ pip install greenmining[dashboard] # flask (web dashboard)
859
+ pip install greenmining[dev] # pytest, black, ruff, mypy (development)
860
+ ```
717
861
 
718
862
  ## License
719
863
 
@@ -1,4 +1,4 @@
1
- greenmining/__init__.py,sha256=wbMwJYwC1HKIPn4w5N6Ux8GV5fAohevW7iO_BYuFuA4,2637
1
+ greenmining/__init__.py,sha256=C9NT6lUmL91LkE0eGUFPrMLvZJYpdhTNYePqZxn1fpg,2909
2
2
  greenmining/__main__.py,sha256=NYOVS7D4w2XDLn6SyXHXPKE5GrNGOeoWSTb_KazgK5c,590
3
3
  greenmining/__version__.py,sha256=xZc02a8bS3vUJlzh8k9RoxemB1irQmq_SpVVj6Cg5M0,62
4
4
  greenmining/config.py,sha256=M4a7AwM1ErCmOY0n5Vmyoo9HPblSkTZ-HD3k2YHzs4A,8340
@@ -37,8 +37,8 @@ greenmining/services/github_fetcher.py,sha256=mUcmQevhdDRYX72O-M7Vi-s3y4ZwNyKewl
37
37
  greenmining/services/github_graphql_fetcher.py,sha256=p76vp5EgStzkmTcws__jb90za8m61toW0CBrwrm5Ew4,11972
38
38
  greenmining/services/local_repo_analyzer.py,sha256=5DMN9RIyGXNdsOlIDV4Mp0fPavbB69oBA9us17P5cNo,24668
39
39
  greenmining/services/reports.py,sha256=Vrw_pBNmVw2mTAf1dpcAqjBe6gXv-O4w_XweoVTt7L8,23392
40
- greenmining-1.0.6.dist-info/licenses/LICENSE,sha256=M7ma3JHGeiIZIs3ea0HTcFl_wLFPX2NZElUliYs4bCA,1083
41
- greenmining-1.0.6.dist-info/METADATA,sha256=cd82RQon4bIBdJT85mcCeZuXL3evl4N9YkcqywDw41k,26920
42
- greenmining-1.0.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
43
- greenmining-1.0.6.dist-info/top_level.txt,sha256=nreXgXxZIWI-42yQknQ0HXtUrFnzZ8N1ra4Mdy2KcsI,12
44
- greenmining-1.0.6.dist-info/RECORD,,
40
+ greenmining-1.0.7.dist-info/licenses/LICENSE,sha256=M7ma3JHGeiIZIs3ea0HTcFl_wLFPX2NZElUliYs4bCA,1083
41
+ greenmining-1.0.7.dist-info/METADATA,sha256=p0Go_jSsrZ04Lvi0-I2HQY1ycWloEbD3agXZnioCFB4,30913
42
+ greenmining-1.0.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
43
+ greenmining-1.0.7.dist-info/top_level.txt,sha256=nreXgXxZIWI-42yQknQ0HXtUrFnzZ8N1ra4Mdy2KcsI,12
44
+ greenmining-1.0.7.dist-info/RECORD,,