We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Need custom FloatField that supports more numeric types
In this code (taken from https://github.com/voxel51/fiftyone/blob/develop/examples/model_inference/README.md), I had to add `float(confidence)` otherwise I got an error about `confidence`, which was a numpy float32 or something similar, not being a supported value for a `mongoengine.fields.FloatField`. 

```py
for imgs, sample_ids in data_loader:
    predictions, confidences = predict(model, imgs)

    # Add predictions to your FiftyOne dataset
    for sample_id, prediction, confidence in zip(
        sample_ids, predictions, confidences
    ):
        sample = dataset[sample_id]
        sample[model_name] = fo.Classification(label=labels_map[prediction])
        sample["confidence"] = float(confidence)  # float() is required here, but shouldn't need to be...
        sample.save()
```

Kind of hard to believe that MongoEngine doesn't handle casting a `np.float32` into a float, but, alas, it seems like our wrapper around `mongoengine.fields.FloatField` will need to override the `validate()` function below to cast non-int types with `float()` as well...

https://github.com/MongoEngine/mongoengine/blob/4275c2d7b791f5910308a4815a1ba39324dee373/mongoengine/fields.py#L377-L411


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `fiftyone/core/fields.py`
Content:
```
1 """
2 Fields of dataset sample schemas.
3 
4 | Copyright 2017-2020, Voxel51, Inc.
5 | `voxel51.com <https://voxel51.com/>`_
6 |
7 """
8 # pragma pylint: disable=redefined-builtin
9 # pragma pylint: disable=unused-wildcard-import
10 # pragma pylint: disable=wildcard-import
11 from __future__ import absolute_import
12 from __future__ import division
13 from __future__ import print_function
14 from __future__ import unicode_literals
15 from builtins import *
16 
17 # pragma pylint: enable=redefined-builtin
18 # pragma pylint: enable=unused-wildcard-import
19 # pragma pylint: enable=wildcard-import
20 
21 import mongoengine.fields
22 
23 
24 class Field(mongoengine.fields.BaseField):
25     pass
26 
27 
28 class BooleanField(mongoengine.BooleanField, Field):
29     pass
30 
31 
32 class IntField(mongoengine.IntField, Field):
33     pass
34 
35 
36 class FloatField(mongoengine.FloatField, Field):
37     pass
38 
39 
40 class StringField(mongoengine.StringField, Field):
41     pass
42 
43 
44 class ListField(mongoengine.ListField, Field):
45     pass
46 
47 
48 class DictField(mongoengine.DictField, Field):
49     pass
50 
51 
52 class EmbeddedDocumentField(mongoengine.EmbeddedDocumentField, Field):
53     pass
54
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/fiftyone/core/fields.py b/fiftyone/core/fields.py
--- a/fiftyone/core/fields.py
+++ b/fiftyone/core/fields.py
@@ -34,7 +34,19 @@
 
 
 class FloatField(mongoengine.FloatField, Field):
-    pass
+    def validate(self, value):
+        try:
+            value = float(value)
+        except OverflowError:
+            self.error("The value is too large to be converted to float")
+        except (TypeError, ValueError):
+            self.error("%s could not be converted to float" % value)
+
+        if self.min_value is not None and value < self.min_value:
+            self.error("Float value is too small")
+
+        if self.max_value is not None and value > self.max_value:
+            self.error("Float value is too large")
 
 
 class StringField(mongoengine.StringField, Field):

{"golden_diff": "diff --git a/fiftyone/core/fields.py b/fiftyone/core/fields.py\n--- a/fiftyone/core/fields.py\n+++ b/fiftyone/core/fields.py\n@@ -34,7 +34,19 @@\n \n \n class FloatField(mongoengine.FloatField, Field):\n-    pass\n+    def validate(self, value):\n+        try:\n+            value = float(value)\n+        except OverflowError:\n+            self.error(\"The value is too large to be converted to float\")\n+        except (TypeError, ValueError):\n+            self.error(\"%s could not be converted to float\" % value)\n+\n+        if self.min_value is not None and value < self.min_value:\n+            self.error(\"Float value is too small\")\n+\n+        if self.max_value is not None and value > self.max_value:\n+            self.error(\"Float value is too large\")\n \n \n class StringField(mongoengine.StringField, Field):\n", "issue": "Need custom FloatField that supports more numeric types\nIn this code (taken from https://github.com/voxel51/fiftyone/blob/develop/examples/model_inference/README.md), I had to add `float(confidence)` otherwise I got an error about `confidence`, which was a numpy float32 or something similar, not being a supported value for a `mongoengine.fields.FloatField`. \r\n\r\n```py\r\nfor imgs, sample_ids in data_loader:\r\n    predictions, confidences = predict(model, imgs)\r\n\r\n    # Add predictions to your FiftyOne dataset\r\n    for sample_id, prediction, confidence in zip(\r\n        sample_ids, predictions, confidences\r\n    ):\r\n        sample = dataset[sample_id]\r\n        sample[model_name] = fo.Classification(label=labels_map[prediction])\r\n        sample[\"confidence\"] = float(confidence)  # float() is required here, but shouldn't need to be...\r\n        sample.save()\r\n```\r\n\r\nKind of hard to believe that MongoEngine doesn't handle casting a `np.float32` into a float, but, alas, it seems like our wrapper around `mongoengine.fields.FloatField` will need to override the `validate()` function below to cast non-int types with `float()` as well...\r\n\r\nhttps://github.com/MongoEngine/mongoengine/blob/4275c2d7b791f5910308a4815a1ba39324dee373/mongoengine/fields.py#L377-L411\r\n\n", "before_files": [{"content": "\"\"\"\nFields of dataset sample schemas.\n\n| Copyright 2017-2020, Voxel51, Inc.\n| `voxel51.com <https://voxel51.com/>`_\n|\n\"\"\"\n# pragma pylint: disable=redefined-builtin\n# pragma pylint: disable=unused-wildcard-import\n# pragma pylint: disable=wildcard-import\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\nfrom builtins import *\n\n# pragma pylint: enable=redefined-builtin\n# pragma pylint: enable=unused-wildcard-import\n# pragma pylint: enable=wildcard-import\n\nimport mongoengine.fields\n\n\nclass Field(mongoengine.fields.BaseField):\n    pass\n\n\nclass BooleanField(mongoengine.BooleanField, Field):\n    pass\n\n\nclass IntField(mongoengine.IntField, Field):\n    pass\n\n\nclass FloatField(mongoengine.FloatField, Field):\n    pass\n\n\nclass StringField(mongoengine.StringField, Field):\n    pass\n\n\nclass ListField(mongoengine.ListField, Field):\n    pass\n\n\nclass DictField(mongoengine.DictField, Field):\n    pass\n\n\nclass EmbeddedDocumentField(mongoengine.EmbeddedDocumentField, Field):\n    pass\n", "path": "fiftyone/core/fields.py"}], "after_files": [{"content": "\"\"\"\nFields of dataset sample schemas.\n\n| Copyright 2017-2020, Voxel51, Inc.\n| `voxel51.com <https://voxel51.com/>`_\n|\n\"\"\"\n# pragma pylint: disable=redefined-builtin\n# pragma pylint: disable=unused-wildcard-import\n# pragma pylint: disable=wildcard-import\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\nfrom builtins import *\n\n# pragma pylint: enable=redefined-builtin\n# pragma pylint: enable=unused-wildcard-import\n# pragma pylint: enable=wildcard-import\n\nimport mongoengine.fields\n\n\nclass Field(mongoengine.fields.BaseField):\n    pass\n\n\nclass BooleanField(mongoengine.BooleanField, Field):\n    pass\n\n\nclass IntField(mongoengine.IntField, Field):\n    pass\n\n\nclass FloatField(mongoengine.FloatField, Field):\n    def validate(self, value):\n        try:\n            value = float(value)\n        except OverflowError:\n            self.error(\"The value is too large to be converted to float\")\n        except (TypeError, ValueError):\n            self.error(\"%s could not be converted to float\" % value)\n\n        if self.min_value is not None and value < self.min_value:\n            self.error(\"Float value is too small\")\n\n        if self.max_value is not None and value > self.max_value:\n            self.error(\"Float value is too large\")\n\n\nclass StringField(mongoengine.StringField, Field):\n    pass\n\n\nclass ListField(mongoengine.ListField, Field):\n    pass\n\n\nclass DictField(mongoengine.DictField, Field):\n    pass\n\n\nclass EmbeddedDocumentField(mongoengine.EmbeddedDocumentField, Field):\n    pass\n", "path": "fiftyone/core/fields.py"}]}