mirror of
https://github.com/karma-riuk/crab.git
synced 2025-07-05 13:38:12 +02:00
added selection field to dataset for manual_selection
This commit is contained in:
15
dataset.py
15
dataset.py
@ -1,5 +1,5 @@
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Dict, List
|
from typing import Dict, List, Optional
|
||||||
import json
|
import json
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
@ -17,6 +17,12 @@ class Comment:
|
|||||||
from_: int
|
from_: int
|
||||||
to: int
|
to: int
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Selection:
|
||||||
|
comment_suggests_change: bool
|
||||||
|
diff_after_address_change: Optional[bool]
|
||||||
|
good: Optional[bool]
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Metadata:
|
class Metadata:
|
||||||
repo: str # the name of the repo, with style XXX/YYY
|
repo: str # the name of the repo, with style XXX/YYY
|
||||||
@ -28,7 +34,7 @@ class Metadata:
|
|||||||
build_system: str = ""
|
build_system: str = ""
|
||||||
reason_for_failure: str = ""
|
reason_for_failure: str = ""
|
||||||
last_cmd_error_msg: str = ""
|
last_cmd_error_msg: str = ""
|
||||||
|
selection: Optional[Selection] = None
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DatasetEntry:
|
class DatasetEntry:
|
||||||
@ -55,13 +61,16 @@ class Dataset:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def from_json(filename: str, keep_still_in_progress: bool = False) -> "Dataset":
|
def from_json(filename: str, keep_still_in_progress: bool = False) -> "Dataset":
|
||||||
with open(filename, "r", encoding="utf-8") as f:
|
with open(filename, "r", encoding="utf-8") as f:
|
||||||
print(f"Loading dataset from {filename}...", end="")
|
print(f"Loading dataset from {filename}...", end=" ", flush=True)
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
for entry_data in data["entries"]:
|
for entry_data in data["entries"]:
|
||||||
metadata_data = entry_data["metadata"]
|
metadata_data = entry_data["metadata"]
|
||||||
|
selection_data = metadata_data["selection"] if "selection" in metadata_data else None
|
||||||
|
selection = Selection(**selection_data) if selection_data else None
|
||||||
|
metadata_data["selection"] = selection
|
||||||
metadata = Metadata(**metadata_data)
|
metadata = Metadata(**metadata_data)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
Reference in New Issue
Block a user