fiftyone.core.odm.runs¶
Dataset run documents.
Classes:
|
Description of a run on a dataset. |
-
class
fiftyone.core.odm.runs.
RunDocument
(*args, **kwargs)¶ Bases:
fiftyone.core.odm.embedded_document.EmbeddedDocument
Description of a run on a dataset.
Attributes:
A dictionary field that wraps a standard Python dictionary.
A unicode string field.
A GridFS storage field.
Datetime field.
A unicode string field.
A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.
Methods:
clean
()Hook for doing document level data cleaning before validation is run.
clear_field
(field_name)Clears the field from the document.
copy
()Returns a deep copy of the document.
fancy_repr
([class_name, select_fields, …])Generates a customizable string representation of the document.
field_to_mongo
(field_name)field_to_python
(field_name, value)from_dict
(d[, extended])Loads the document from a BSON/JSON dictionary.
from_json
(s)Loads the document from a JSON string.
get_field
(field_name)Gets the field of the document.
Get text score from text query
has_field
(field_name)Determines whether the document has a field of the given name.
set_field
(field_name, value[, create])Sets the value of a field of the document.
to_dict
([extended])Serializes this document to a BSON/JSON dictionary.
to_json
([pretty_print])Serializes the document to a JSON string.
to_mongo
(*args, **kwargs)Return as SON data ready for use with MongoDB.
validate
([clean])Ensure that all fields’ values are valid and that required fields are present.
Classes:
alias of
mongoengine.base.metaclasses.DocumentMetaclass
-
key
¶ A unicode string field.
-
version
¶ A unicode string field.
-
timestamp
¶ Datetime field.
Uses the python-dateutil library if available alternatively use time.strptime to parse the dates. Note: python-dateutil’s parser is fully featured and when installed you can utilise it to convert varying types of date formats into valid python datetime objects.
Note: To default the field to the current datetime, use: DateTimeField(default=datetime.utcnow)
- Note: Microseconds are rounded to the nearest millisecond.
Pre UTC microsecond support is effectively broken. Use
ComplexDateTimeField
if you need accurate microsecond support.
-
config
¶ A dictionary field that wraps a standard Python dictionary. This is similar to an embedded document, but the structure is not defined.
Note
Required means it cannot be empty - as the default for DictFields is {}
New in version 0.3.
Changed in version 0.5: - Can now handle complex / varying types of data
-
view_stages
¶ A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.
If using with ReferenceFields see: one-to-many-with-listfields
Note
Required means it cannot be empty - as the default for ListFields is []
-
results
¶ A GridFS storage field.
New in version 0.4.
Changed in version 0.5: added optional size param for read
Changed in version 0.6: added db_alias for multidb support
-
STRICT
= False¶
-
clean
()¶ Hook for doing document level data cleaning before validation is run.
Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
-
clear_field
(field_name)¶ Clears the field from the document.
- Parameters
field_name – the field name
- Raises
ValueError – if the field does not exist
-
copy
()¶ Returns a deep copy of the document.
- Returns
a
SerializableDocument
-
fancy_repr
(class_name=None, select_fields=None, exclude_fields=None, **kwargs)¶ Generates a customizable string representation of the document.
- Parameters
class_name (None) – optional class name to use
select_fields (None) – iterable of field names to restrict to
exclude_fields (None) – iterable of field names to exclude
**kwargs – additional key-value pairs to include in the string representation
- Returns
a string representation of the document
-
field_to_mongo
(field_name)¶
-
field_to_python
(field_name, value)¶
-
classmethod
from_dict
(d, extended=False)¶ Loads the document from a BSON/JSON dictionary.
- Parameters
d – a dictionary
extended (False) – whether the input dictionary may contain serialized extended JSON constructs
- Returns
a
SerializableDocument
-
classmethod
from_json
(s)¶ Loads the document from a JSON string.
- Returns
a
SerializableDocument
-
get_field
(field_name)¶ Gets the field of the document.
- Parameters
field_name – the field name
- Returns
the field value
- Raises
AttributeError – if the field does not exist
-
get_text_score
()¶ Get text score from text query
-
has_field
(field_name)¶ Determines whether the document has a field of the given name.
- Parameters
field_name – the field name
- Returns
True/False
-
my_metaclass
¶ alias of
mongoengine.base.metaclasses.DocumentMetaclass
Methods:mro
Return a type’s method resolution order.
-
set_field
(field_name, value, create=False)¶ Sets the value of a field of the document.
- Parameters
field_name – the field name
value – the field value
create (False) – whether to create the field if it does not exist
- Raises
ValueError – if
field_name
is not an allowed field name or does not exist andcreate == False
-
to_dict
(extended=False)¶ Serializes this document to a BSON/JSON dictionary.
- Parameters
extended (False) – whether to serialize extended JSON constructs such as ObjectIDs, Binary, etc. into JSON format
- Returns
a dict
-
to_json
(pretty_print=False)¶ Serializes the document to a JSON string.
- Parameters
pretty_print (False) – whether to render the JSON in human readable format with newlines and indentations
- Returns
a JSON string
-
to_mongo
(*args, **kwargs)¶ Return as SON data ready for use with MongoDB.
-
validate
(clean=True)¶ Ensure that all fields’ values are valid and that required fields are present.
Raises
ValidationError
if any of the fields’ values are found to be invalid.
-