Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App distributions fixes #1817

Merged
merged 5 commits into from
Jun 20, 2022
Merged

App distributions fixes #1817

merged 5 commits into from
Jun 20, 2022

Conversation

benjaminpkane
Copy link
Contributor

Changelog

  • Fixes bar count by passing intended bar limit of 200 to distribution aggregations
  • Fixes None support for date and datetime fields in distributions

Issues

Code

from datetime import date, datetime, timedelta
import fiftyone as fo

today = date.today()
now = datetime.now()

dataset, session = fo.quickstart()
dataset = dataset.clone("iss-1816")

for idx, sample in enumerate(dataset.limit(10)):
    # Date-only
    sample["dates"] = today - timedelta(days=idx)

    # Date and time
    sample["ms"] = now - timedelta(milliseconds=idx)
    sample["seconds"] = now - timedelta(seconds=idx)
    sample["minutes"] = now - timedelta(minutes=idx)
    sample["hours"] = now - timedelta(hours=idx)
    sample["days"] = now - timedelta(days=idx)
    sample["weeks"] = now - timedelta(weeks=idx)
    sample.save()

session.dataset = dataset # check distrubutions (Labels and Other)

@benjaminpkane benjaminpkane added bug Bug fixes app Issues related to App features labels Jun 2, 2022
@benjaminpkane benjaminpkane requested a review from a team June 2, 2022 21:13
@benjaminpkane benjaminpkane self-assigned this Jun 2, 2022
@brimoor
Copy link
Contributor

brimoor commented Jun 3, 2022

I get the following error when running your example code and then trying to view Other fields graphs:

Traceback (most recent call last):
File "/Users/Brian/dev/fiftyone/fiftyone/server/decorators.py", line 33, in wrapper
response = await func(endpoint, request, data, *args)
File "/Users/Brian/dev/fiftyone/fiftyone/server/routes/distributions.py", line 99, in post
results = await _gather_results(aggs, fields, paths, view, ticks)
File "/Users/Brian/dev/fiftyone/fiftyone/server/routes/distributions.py", line 175, in _gather_results
response = await view._async_aggregate(aggs)
File "/Users/Brian/dev/fiftyone/fiftyone/core/collections.py", line 7093, in _async_aggregate
_results = await foo.aggregate(collection, pipelines)
File "/Users/Brian/dev/fiftyone/fiftyone/core/odm/database.py", line 321, in _do_async_pooled_aggregate
return await asyncio.gather(
File "/Users/Brian/dev/fiftyone/fiftyone/core/odm/database.py", line 327, in _do_async_aggregate
return [i async for i in collection.aggregate(pipeline, allowDiskUse=True)]
File "/Users/Brian/dev/fiftyone/fiftyone/core/odm/database.py", line 327, in <listcomp>
return [i async for i in collection.aggregate(pipeline, allowDiskUse=True)]
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/motor/core.py", line 1158, in next
if self.alive and (self._buffer_size() or await self._get_more()):
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/motor/core.py", line 1626, in _on_started
pymongo_cursor = future.result()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/pymongo/collection.py", line 2502, in aggregate
return self._aggregate(_CollectionAggregationCommand,
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/pymongo/collection.py", line 2419, in _aggregate
return self.__database.client._retryable_read(
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1525, in _retryable_read
return func(session, server, sock_info, secondary_ok)
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/pymongo/aggregation.py", line 137, in get_cursor
result = sock_info.command(
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/pymongo/pool.py", line 710, in command
return command(self, dbname, spec, secondary_ok,
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/pymongo/network.py", line 161, in command
helpers._check_command_response(
File "/Users/Brian/dev/env/fo/lib/python3.9/site-packages/pymongo/helpers.py", line 167, in _check_command_response
raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: The 'boundaries' option to $bucket must be sorted, but elements 0 and 1 are not in ascending order (2022-06-02T20:03:06.436Z is not less than 2022-06-02T20:03:06.436Z)., full error: {'ok': 0.0, 'errmsg': "The 'boundaries' option to $bucket must be sorted, but elements 0 and 1 are not in ascending order (2022-06-02T20:03:06.436Z is not less than 2022-06-02T20:03:06.436Z).", 'code': 40194, 'codeName': 'Location40194'}

@benjaminpkane
Copy link
Contributor Author

Ok, fixed

Copy link
Contributor

@brimoor brimoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benjaminpkane benjaminpkane merged commit cc9ab9f into develop Jun 20, 2022
@benjaminpkane benjaminpkane deleted the iss-1816 branch June 20, 2022 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Issues related to App features bug Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Labels' graph is incomplete and Other fields's graph throws a TypeError
2 participants