voxel51 / fiftyone

The open-source tool for building high-quality datasets and computer vision models
https://fiftyone.ai
Apache License 2.0
7.93k stars 521 forks source link

Wrong DateField value loaded from MongoDB #4365

Closed rikirolly closed 2 months ago

rikirolly commented 2 months ago

Describe the problem

I load a persistent dataset from MongoDB with the instruction: dataset = fo.load_dataset(dataset_name)

This is the print from the first sample:

print(f"{sample['filepath']}\n{sample['date']} - {sample['datetime']}") 
/root/fiftyone/global/2023/2023-09-08/d30adad1335f04da4bf928c0f023768374fafeca15d94dc94f0265c8a73de8630e3c37fcf972a43059d4b5897061fdff82605d2f03675d8e90862b6cee94415e.jpg
2023-09-07 - 2023-09-08 11:36:17

where the date value 2023-09-07 is wrong. It must be 2023-09-08.

Checking the same sample directly into MongoDB I get these values that seems correct:

{
    "_id": {
        "$oid": "662266926a533ff7fe32ddef"
    },
    "filepath": "/root/fiftyone/global/2023/2023-09-08/d30adad1335f04da4bf928c0f023768374fafeca15d94dc94f0265c8a73de8630e3c37fcf972a43059d4b5897061fdff82605d2f03675d8e90862b6cee94415e.jpg",
    "tags": [],
    "_media_type": "image",
    "_rand": 0.9997939277596051,
    "ground_truth": {
        "_id": {
            "$oid": "662266916a533ff7fe32ddee"
        },
        "_cls": "Classification",
        "tags": [],
        "label": "Lifted Electrode"
    },
    "datetime": {
        "$date": {
            "$numberLong": "1694172977000"
        }
    },
    "year": 2023,
    "date": {
        "$date": {
            "$numberLong": "1694131200000"
        }
    },
    "_dataset_id": {
        "$oid": "662266916a533ff7fe32dded"
    }
}

Code to reproduce issue

I don't know if my localization in Rome could be a possible problem.

System information

Other info/logs

Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the FiftyOne codebase?

gboeer commented 2 months ago

Indeed, 1694131200000 should translate to Fri Sep 08 2023 00:00:00 GMT+0000 and 1694172977000 to Fri Sep 08 2023 11:36:17 GMT+0000

swheaton commented 2 months ago

@rikirolly thanks for the report I think I found the issue hold tight!!

swheaton commented 2 months ago

thank you @rikirolly for the bug report, there should be a fix coming in v0.24.0 🙌🏼