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

Error raised when no data exists in specified time range #8

Closed
joacorapela opened this issue Jun 15, 2021 · 5 comments · Fixed by #7
Closed

Error raised when no data exists in specified time range #8

joacorapela opened this issue Jun 15, 2021 · 5 comments · Fixed by #7
Assignees
Labels
bug Something isn't working

Comments

@joacorapela
Copy link

There is a problem in the function aeon.query.pelletdata for longer start times, but not for shorter ones.
The code bellow runs well with a shorter star_time=600 but raises an error for a larger start_time=14000

$ python doBugReport061521.py --start_time=16000
ValueError: No objects to concatenate
/nfs/ghome/live/rapela/anaconda3/envs/aeon_env/lib/python3.9/site-packages/pandas/core/reshape/concat.py(342)init()
340
341 if len(objs) == 0:
--> 342 raise ValueError("No objects to concatenate")

import sys
import pdb
import datetime
import argparse

import aeon.preprocess.utils
from aeon.query import exp0_api
                                                                                                                                                                                                                                                                                  

def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument("--root", help="Root path for data access", default="/ceph/aeon/test2/experiment0.1")
    parser.add_argument("--session", help="Session index", default=3, type=int)
    parser.add_argument("--start_time", help="Start time (sec)", default=0.0, type=float)
    parser.add_argument("--duration", help="Duration (sec)", default=14000.0, type=float)
    parser.add_argument("--patch_name", help="Patch name", default="Patch2")

    args = parser.parse_args()

    root = args.root
    session = args.session
    t0_relative = args.start_time
    requested_duration = args.duration
    tf_relative = args.start_time+args.duration
    patch_name = args.patch_name

    metadata = exp0_api.sessiondata(root)
    metadata = metadata[metadata.id.str.startswith('BAA')]
    metadata = aeon.preprocess.utils.getPairedEvents(metadata=metadata)
    metadata = exp0_api.sessionduration(metadata)

    session_duration_sec = metadata.iloc[session].duration.total_seconds()
    if requested_duration>session_duration_sec:
        raise ValueError("Requested duration {:f} exceeds the session duration {:f}".format(requested_duration, session_duration_sec))
    print("Session duration {:f}".format(session_duration_sec))

    session_start = metadata.index[session]
    t0_absolute = session_start + datetime.timedelta(seconds=t0_relative)
    tf_absolute = session_start + datetime.timedelta(seconds=tf_relative)
    pellet_vals = exp0_api.pelletdata(root, patch_name, start=t0_absolute, end=tf_absolute)

    pdb.set_trace()

if __name__=="__main__":
    main(sys.argv)
@joacorapela joacorapela added the bug Something isn't working label Jun 15, 2021
@glopesdev
Copy link
Contributor

At first glance this means that no data was found inside the specified interval. I do agree that it should return an empty data frame instead of throwing an error. Will fix it soon.

@joacorapela
Copy link
Author

Thanks for your quick reply @glopesdev
Note that the requested start_time=14000 and duration=600 are within the session duration

Session duration 15548.271639

@glopesdev
Copy link
Contributor

Yes, sorry what I meant when I said "no data" is that maybe no pellets were delivered during that time, so in that case there would be no events to report.

@joacorapela
Copy link
Author

At other times there are no pellets delivered but I did not get an error.

@glopesdev
Copy link
Contributor

glopesdev commented Jun 16, 2021

This turned out to be a more general issue around querying time ranges where no data has been recorded (e.g. in case of a crash). I'm pushing a fix now on the exp01-api branch.

@glopesdev glopesdev changed the title Problem in aeon.query.pelletdata Error raised when no data exists in specified time range Jun 16, 2021
@glopesdev glopesdev linked a pull request Jun 16, 2021 that will close this issue
iamamutt pushed a commit that referenced this issue Aug 26, 2021
Fix row skipping when replacing header names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants