now.utils module#
- now.utils.maybe_prompt_user(questions, attribute, **kwargs)[source]#
Checks the kwargs for the attribute name. If present, the value is returned directly. If not, the user is prompted via the cmd-line using the questions argument.
- Parameters
questions – A dictionary that is passed to PyInquirer.prompt See docs: https://github.com/CITGuru/PyInquirer#documentation
attribute – Name of the value to get. Make sure this matches the name in kwargs
- Returns
A single value of either from kwargs or the user cli input.
- now.utils.flatten_dict(d, parent_key='', sep='__')[source]#
This function converts a nested dictionary into a dictionary of attirbutes using ‘__’ as a separator. Example:
{‘a’: {‘b’: {‘c’: 1, ‘d’: 2}}} -> {‘a__b__c’: 1, ‘a__b__c’: 2}
- class now.utils.Dumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]#
Bases:
Dumper
- now.utils.docarray_typing_to_modality_string(T)[source]#
E.g. docarray.typing.Image -> image
- Return type
str