mirror of
https://github.com/clearml/clearml
synced 2025-02-07 13:23:40 +00:00
Add support for extra fields in request object
This commit is contained in:
parent
fb6fd9ac4a
commit
cf9671c253
@ -11,8 +11,19 @@ class Request(ApiModel):
|
||||
_method = 'get'
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs:
|
||||
allow_extra_fields = kwargs.pop("_allow_extra_fields_", False)
|
||||
if not allow_extra_fields and kwargs:
|
||||
raise ValueError('Unsupported keyword arguments: %s' % ', '.join(kwargs.keys()))
|
||||
elif allow_extra_fields and kwargs:
|
||||
self._extra_fields = kwargs
|
||||
else:
|
||||
self._extra_fields = {}
|
||||
|
||||
def to_dict(self, *args, **kwargs):
|
||||
res = super(Request, self).to_dict(*args, **kwargs)
|
||||
if self._extra_fields:
|
||||
res.update(self._extra_fields)
|
||||
return res
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
|
Loading…
Reference in New Issue
Block a user