Skip to content

Commit

Permalink
Fix os.makedirs calls for optional Path variables
Browse files Browse the repository at this point in the history
Previously, `os.makedirs` was called directly on variables like `MESSAGE_CACHE`
or `CODE_CACHE`, which could be `None`. This caused issues with `mypy` and potential
runtime errors since `os.makedirs` does not handle `None`.

The fix ensures these variables are checked for `None` before calling `os.makedirs`,
preventing invalid operations and aligning with type checks.

fix: wrong name
  • Loading branch information
Antonyjin committed Nov 22, 2024
1 parent 0ed3520 commit cd88144
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/aleph/vm/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,14 @@ def setup(self):
STREAM_CHAINS[Chain.AVAX].rpc = str(self.RPC_AVAX)
STREAM_CHAINS[Chain.BASE].rpc = str(self.RPC_BASE)

os.makedirs(self.MESSAGE_CACHE, exist_ok=True)
os.makedirs(self.CODE_CACHE, exist_ok=True)
os.makedirs(self.RUNTIME_CACHE, exist_ok=True)
os.makedirs(self.DATA_CACHE, exist_ok=True)
if self.MESSAGE_CACHE:
os.makedirs(self.MESSAGE_CACHE, exist_ok=True)
if self.CODE_CACHE:
os.makedirs(self.CODE_CACHE, exist_ok=True)
if self.RUNTIME_CACHE:
os.makedirs(self.RUNTIME_CACHE, exist_ok=True)
if self.DATA_CACHE:
os.makedirs(self.DATA_CACHE, exist_ok=True)

os.makedirs(self.EXECUTION_ROOT, exist_ok=True)

Expand All @@ -422,10 +426,14 @@ def setup(self):

self.LINUX_PATH = linux_path_on_device

os.makedirs(self.EXECUTION_LOG_DIRECTORY, exist_ok=True)
os.makedirs(self.PERSISTENT_VOLUMES_DIR, exist_ok=True)
os.makedirs(self.CONFIDENTIAL_DIRECTORY, exist_ok=True)
os.makedirs(self.CONFIDENTIAL_SESSION_DIRECTORY, exist_ok=True)
if self.EXECUTION_LOG_DIRECTORY:
os.makedirs(self.EXECUTION_LOG_DIRECTORY, exist_ok=True)
if self.PERSISTENT_VOLUMES_DIR:
os.makedirs(self.PERSISTENT_VOLUMES_DIR, exist_ok=True)
if self.CONFIDENTIAL_DIRECTORY:
os.makedirs(self.CONFIDENTIAL_DIRECTORY, exist_ok=True)
if self.CONFIDENTIAL_SESSION_DIRECTORY:
os.makedirs(self.CONFIDENTIAL_SESSION_DIRECTORY, exist_ok=True)

self.API_SERVER = self.API_SERVER.rstrip("/")

Expand Down

0 comments on commit cd88144

Please sign in to comment.