Unverified Commit 54e688b6 authored by アマデウス's avatar アマデウス Committed by GitHub
Browse files

moved ensure_path_exists to utils.common (#591)

parent e956d93a
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import os
import random
import socket
from pathlib import Path
from typing import List, Union
import torch
......@@ -39,6 +41,13 @@ def print_rank_0(msg: str, logger=None):
logger.info(msg)
def ensure_path_exists(filename: str):
# ensure the path exists
dirpath = os.path.dirname(filename)
if not os.path.exists(dirpath):
Path(dirpath).mkdir(parents=True, exist_ok=True)
def free_port():
while True:
try:
......@@ -103,7 +112,6 @@ def conditional_context(context_manager, enable=True):
class model_branch_context(object):
def __enter__(self):
self.env_status = env.save()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment