Update environment.py
Browse files- environment.py +6 -2
environment.py
CHANGED
|
@@ -13,14 +13,18 @@ DEFAULT_DATASET_PATH = BASE_DIR / "dataset.json"
|
|
| 13 |
class SecurityEnv:
|
| 14 |
def __init__(self, dataset_path=None):
|
| 15 |
dataset_file = Path(dataset_path) if dataset_path else DEFAULT_DATASET_PATH
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
dataset_file = BASE_DIR / dataset_file
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
with dataset_file.open("r", encoding="utf-8") as handle:
|
| 20 |
self.data = json.load(handle)
|
| 21 |
|
| 22 |
self.current_sample = None
|
| 23 |
-
self.step_count = 0
|
| 24 |
|
| 25 |
def reset(self):
|
| 26 |
self.current_sample = random.choice(self.data)
|
|
|
|
| 13 |
class SecurityEnv:
|
| 14 |
def __init__(self, dataset_path=None):
|
| 15 |
dataset_file = Path(dataset_path) if dataset_path else DEFAULT_DATASET_PATH
|
| 16 |
+
|
| 17 |
+
# only join if relative
|
| 18 |
+
if not dataset_file.exists():
|
| 19 |
dataset_file = BASE_DIR / dataset_file
|
| 20 |
|
| 21 |
+
if not dataset_file.exists():
|
| 22 |
+
raise FileNotFoundError(f"Dataset not found: {dataset_file}")
|
| 23 |
+
|
| 24 |
with dataset_file.open("r", encoding="utf-8") as handle:
|
| 25 |
self.data = json.load(handle)
|
| 26 |
|
| 27 |
self.current_sample = None
|
|
|
|
| 28 |
|
| 29 |
def reset(self):
|
| 30 |
self.current_sample = random.choice(self.data)
|