Skip to content

Commit

Permalink
github CI should be ok, let's see circleci now
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Jul 10, 2024
1 parent fbfa8dd commit 9d023d2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
File renamed without changes.
16 changes: 1 addition & 15 deletions grid2op/Environment/baseEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4036,7 +4036,6 @@ def _aux_gen_classes(cls_other, sys_path, _add_class_output=False):
raise RuntimeError(f"cls_other should be a type and not an object !: {cls_other}")
if not issubclass(cls_other, GridObjects):
raise RuntimeError(f"cls_other should inherit from GridObjects: {cls_other}")
print(f"DEBUG CI Start {cls_other.__name__}")

from pathlib import Path
path_env = cls_other._PATH_GRID_CLASSES
Expand All @@ -4062,7 +4061,6 @@ def _aux_gen_classes(cls_other, sys_path, _add_class_output=False):
f"Check class {cls_other.__name__}")
str_import = None
if not _add_class_output:
print(f"\tDEBUG CIsuccess for {cls_other.__name__}")
return str_import

# NB: these imports needs to be consistent with what is done in
Expand Down Expand Up @@ -4103,21 +4101,10 @@ def _aux_gen_classes(cls_other, sys_path, _add_class_output=False):
try:
module = importlib.import_module(f".{nm_}", package=tmp_nm)
except ModuleNotFoundError as exc_:
print("##########################################")
print("#### ERROR HERE #####")
print("##########################################")
print(f"DEBUG CI: {super_module}")
print(f"DEBUG CI: {super_module.__dict__}")
print(f"DEBUG CI: {sys.path}")
print(f"DEBUG CI: {sorted(os.listdir(sub_repo))}")
print(f"DEBUG CI: {sorted(os.listdir(os.path.join(sub_repo, tmp_nm)))}")
# invalidate the cache and reload the package in this case
importlib.invalidate_caches()
importlib.reload(super_module)
print(f"DEBUG CI: {super_module.__dict__}")
module = importlib.import_module(f".{nm_}", package=tmp_nm)
# cls_for_test = importlib.import_module(f"{tmp_nm}.Environment_l2rpn_case14_sandbox_file")
# raise EnvError(f"Impossible to load the class {tmp_nm}.{nm_}") from exc_
print(f"\tsuccess for {cls_other.__name__}")
cls_res = getattr(module, cls_other.__name__)
return str_import, cls_res

Expand Down Expand Up @@ -4225,7 +4212,6 @@ def generate_classes(self, *, local_dir_id=None, _guard=None, _is_base_env__=Tru
_init_txt = _init_txt

# generate the classes
print(f"DEBUG CI: {_is_base_env__ = }")
# for the environment
txt_ = self._aux_gen_classes(type(self), sys_path)
if txt_ is not None:
Expand Down
4 changes: 3 additions & 1 deletion grid2op/Space/GridObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2962,7 +2962,9 @@ def init_grid(cls, gridobj, force=False, extra_name=None, force_module=None, _lo
# AND the module is added to the path

# check that it matches (security / consistency check)
if _local_dir_cls.name != gridobj._PATH_GRID_CLASSES:
if not os.path.samefile(_local_dir_cls.name , gridobj._PATH_GRID_CLASSES):
# in windows the string comparison fails because of things like "/", "\" or "\\"
# this is why we use "samefile"
raise EnvError(f"Unable to create the class: mismatch between "
f"_local_dir_cls ({_local_dir_cls.name}) and "
f" _PATH_GRID_CLASSES ({gridobj._PATH_GRID_CLASSES})")
Expand Down
2 changes: 0 additions & 2 deletions grid2op/tests/automatic_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ def test_all_classes_from_file(self,
name_action_cls = self._aux_get_act_cls().format(classes_name)

name_action_cls = name_action_cls.format(classes_name)
print("DEBUG CI making the env")
env = self._aux_make_env(env)
print("DEBUG CI env made")
names_cls = [f"ActionSpace_{classes_name}",
f"_BackendAction_{classes_name}",
f"CompleteAction_{classes_name}",
Expand Down

0 comments on commit 9d023d2

Please sign in to comment.