summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/kconfig.py13
-rw-r--r--lib/loader/kconfig.py6
-rw-r--r--lib/utils.py12
3 files changed, 18 insertions, 13 deletions
diff --git a/lib/kconfig.py b/lib/kconfig.py
index 164630b..a440b81 100644
--- a/lib/kconfig.py
+++ b/lib/kconfig.py
@@ -8,8 +8,7 @@ import re
import shutil
import subprocess
-from contextlib import contextmanager
-
+from .utils import cd
from versuchung.experiment import Experiment
from versuchung.types import String, Bool, Integer
from versuchung.files import File, Directory
@@ -17,16 +16,6 @@ from versuchung.files import File, Directory
logger = logging.getLogger(__name__)
-@contextmanager
-def cd(path):
- old_dir = os.getcwd()
- os.chdir(path)
- try:
- yield
- finally:
- os.chdir(old_dir)
-
-
class AttributeExperiment(Experiment):
outputs = {
"config": File(".config"),
diff --git a/lib/loader/kconfig.py b/lib/loader/kconfig.py
index 631892f..42181c9 100644
--- a/lib/loader/kconfig.py
+++ b/lib/loader/kconfig.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from .. import kconfiglib
+from dfatool.utils import cd
from frozendict import frozendict
import json
import os
@@ -20,7 +21,10 @@ class KConfigAttributes:
elif os.path.exists(config_path):
failed_experiments.append(config_path)
- kconf = kconfiglib.Kconfig(kconfig_path)
+ kconfig_dir = "/".join(kconfig_path.split("/")[:-1])
+
+ with cd(kconfig_dir):
+ kconf = kconfiglib.Kconfig(kconfig_path)
self.kconf = kconf
self.kconfig_hash = self.file_hash(kconfig_path)
diff --git a/lib/utils.py b/lib/utils.py
index 86829b3..10f0172 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -2,13 +2,25 @@
import json
import numpy as np
+import os
import re
import logging
+from contextlib import contextmanager
from sklearn.metrics import r2_score
logger = logging.getLogger(__name__)
+@contextmanager
+def cd(path):
+ old_dir = os.getcwd()
+ os.chdir(path)
+ try:
+ yield
+ finally:
+ os.chdir(old_dir)
+
+
class NpEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.integer):