optimization_metadata.io_dill   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 12
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A load_object() 0 5 2
A save_object() 0 6 3
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
import os
6
import dill
7
8
9
def save_object(path, name, _object):
10
    if not os.path.exists(path):
11
        os.makedirs(path, exist_ok=True)
12
13
    with open(path + name + ".pkl", "wb") as dill_file:
14
        dill.dump(_object, dill_file)
15
16
17
def load_object(path, name):
18
    with open(path + name + ".pkl", "rb") as dill_file:
19
        _object = dill.load(dill_file)
20
21
    return _object
22