[b596db]: / mylib / dataloader / path_manager.py

Download this file

34 lines (24 with data), 737 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import json
class PathManager:
def __init__(self, cfg_path=None):
self.environ = parse_environ(cfg_path)
@property
def base(self):
return self.environ['DATASET']
@property
def info(self):
import pandas as pd
df = pd.read_csv(os.path.join(self.base, 'info.csv'))
return df
@property
def nodule_path(self):
return os.path.join(self.base, 'nodule')
def parse_environ(cfg_path=None):
if cfg_path is None:
cfg_path = os.path.join(os.path.dirname(__file__), "ENVIRON")
assert os.path.exists(cfg_path), "`ENVIRON` does not exists."
with open(cfg_path) as f:
environ = json.load(f)
return environ
PATH = PathManager()