gwrun argspec#30
Conversation
|
For a sense of how this is going to be used, see: girder/girder_worker#314 |
| if isinstance(doc, bytes): | ||
| doc = doc.decode('utf-8') | ||
| else: | ||
| doc = cleandoc(doc) |
There was a problem hiding this comment.
yeah, not sure where that came from
| return self._construct_argument( | ||
| self._get_class(self._signature.parameters[key]), key) | ||
|
|
||
| def _construct_argument(self, cls, name, **kwargs): |
There was a problem hiding this comment.
**kwargs seems to be pointless here. Also, I would avoid the cls parameter name because it makes the function read as a class method below.
| raise TypeError('Expected argument name to be a string') | ||
|
|
||
| data_type = kwargs.get("data_type", None) | ||
| if data_type is not None and callable(data_type): |
| def description(): | ||
| return getattr(func, GWFuncDesc._func_desc_attr) | ||
|
|
||
| func.description = description |
There was a problem hiding this comment.
Why have both this and GWFuncDesc.get_description?
There was a problem hiding this comment.
mainly for compatibility with code that's already been written (e.g. item_tasks?) I can just drop it if nothing is actually using it
Handling instance bound variables (i.e. 'self') will have to be solved in the CLI.
|
I'm happy to roll 99cd62d back if we don't want to add the deprecation mechanism. It just seems like a better way to signal to downstreams that we're moving away from something. It might not make the most sense to start with girder_worker_utils, but GWU has been providing a nice test bed for stuff like this |
This allows metadata mapping for each type of argument to be defined on the consumers' (e.g. CLI) classes
This PR creates a decorator
parameterthat allows for arbitrary association of metadata with a callable's argument list.This metadata is exposed through an attribute on the callable as a
GWFuncDescobject which has an API for accessing argument metdata. E.G.The ultimate goal is to use this metadata for automatic generation of CLI & Web UI tools from Girder Worker tasks