mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Add configuration utilities
This commit is contained in:
parent
cc5da546fa
commit
9b3d107934
@ -16,3 +16,7 @@ class attrs(object):
|
|||||||
|
|
||||||
def __call__(self, f):
|
def __call__(self, f):
|
||||||
return attr.attrs(*self.args, **self.kwargs)(f)
|
return attr.attrs(*self.args, **self.kwargs)(f)
|
||||||
|
|
||||||
|
|
||||||
|
def readonly(value):
|
||||||
|
return property(lambda self: value)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
import six
|
import six
|
||||||
import humanfriendly
|
import humanfriendly
|
||||||
import pyparsing
|
import pyparsing
|
||||||
@ -81,3 +83,16 @@ def text_to_config_dict(text):
|
|||||||
six.raise_from(ValueError("Could not parse configuration text ({}):\n{}".format(pos, text)), None)
|
six.raise_from(ValueError("Could not parse configuration text ({}):\n{}".format(pos, text)), None)
|
||||||
except Exception:
|
except Exception:
|
||||||
six.raise_from(ValueError("Could not parse configuration text:\n{}".format(text)), None)
|
six.raise_from(ValueError("Could not parse configuration text:\n{}".format(text)), None)
|
||||||
|
|
||||||
|
|
||||||
|
def verify_basic_value(value):
|
||||||
|
# return True if value of of basic type (json serializable)
|
||||||
|
if not isinstance(value,
|
||||||
|
six.string_types + six.integer_types +
|
||||||
|
(six.text_type, float, list, tuple, dict, type(None))):
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
json.dumps(value)
|
||||||
|
return True
|
||||||
|
except TypeError:
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user