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

Filtering on experiments: Date #35

Open
chovanecm opened this issue May 8, 2017 · 8 comments
Open

Filtering on experiments: Date #35

chovanecm opened this issue May 8, 2017 · 8 comments
Labels

Comments

@chovanecm
Copy link
Owner

A researcher wants to limit the list of experiment runs to
runs that have a certain property on, before, after or on another date than the given date so that he can filter the results e.g. by the experiment start time.

@chovanecm chovanecm added the draft label May 8, 2017
@chovanecm chovanecm mentioned this issue May 8, 2017
7 tasks
@Ori226
Copy link

Ori226 commented May 23, 2018

Any progress?

@chovanecm
Copy link
Owner Author

Not from my side.

@Ori226
Copy link

Ori226 commented May 23, 2018

I'm thinking of trying to implement search by date. @chovanecm, you think you can guide be about how to do that? can someone else?

I'm not familiar with the sacredboard code, but I hope it will only involve transforming "2017-11-13 07:20:41.810Z" string into ISODate("2017-11-13 07:20:41.810Z").

Any thoughts?

@chovanecm
Copy link
Owner Author

chovanecm commented May 23, 2018

That would be great!
I have (better late than never) started writing development guide for Sacredboard, though it is not complete yet.
You can first try setting your dev environment and making sure you can start sacredboard from source and run tests:

https://github.com/chovanecm/sacredboard/wiki/Development-Guide

I will provide you more info soon (perhaps you can just have quick look in the meantime at my comment describing the design for a different ticket: #77 )

@chovanecm
Copy link
Owner Author

Well,
I think there are several parts that need to be modified or extended.
Currently, the value is transferred either as a "string" (in quotes) or as a number from the frontend to the backend.
A single filter is transferred as JSON, e.g.: {"field":"command","operator":"==","value":"runExperiment"}
or {"field":"result","operator":"==","value": 123456}

When parsed on the backend, the system has an easy job telling whether the value is a string or a number. But as far as I know, there is no typed way for storing dates in JSON.
In order for the backend to know it should handle the input as a date, we must tell it.
There are of course several ways to do this.
We could do something quite ugly like writing date as {"field":"someDate","operator":"==","value":"Date(2018-05-27T..."} (but what if someone wants to search for Date(...) as string?)
Therefore I am thinking of a different representation for the filter for date values, something like
{"field":"someDate","operator":"==","dateValue":"2012-04-23T18:25:43.511Z"}

or maybe better {"field":"someDate","operator":"==","value":"2012-04-23T18:25:43.511Z", "valueType": "DateTime"}

Here is a link to the place where the filter value is read by the backend.
I know it was not very clever from me to put query decoding to the PyMongo data access layer (as the principle would be the same for other database backends), but this may change later.

By the way, the URL generated by DataTables for retreiving experiment list contains the filters: There are joined either using logical disjunction ("or") or conjunction ("and") and can be nested. You can use it for testing after you modify the backend:

http://localhost:5000/api/run?draw=6&queryFilter={"type":"and","filters":[{"type":"or","filters":[{"field":"status","operator":"==","value":"RUNNING"},{"field":"status","operator":"==","value":"COMPLETED"},{"field":"status","operator":"==","value":"QUEUED"},{"field":"status","operator":"==","value":"FAILED"},{"field":"status","operator":"==","value":"INTERRUPTED"},{"field":"status","operator":"==","value":"DEAD"},{"field":"status","operator":"==","value":"TIMEOUT"}]},{"field":"command","operator":"==","value":"runExperiment"}]}&_=1527418064311

After that modification, the following URL should work for you:
http://localhost:5000/api/run?draw=6&queryFilter={"type":"and","filters":[{"type":"or","filters":[{"field":"status","operator":"==","value":"RUNNING"},{"field":"status","operator":"==","value":"COMPLETED"},{"field":"status","operator":"==","value":"QUEUED"},{"field":"status","operator":"==","value":"FAILED"},{"field":"status","operator":"==","value":"INTERRUPTED"},{"field":"status","operator":"==","value":"DEAD"},{"field":"status","operator":"==","value":"TIMEOUT"}]},{"field":"start_time","operator":">","value":"2018-05-27T18:25:43.511Z", "valueType": "DateTime"}]}&_=1527418064311

(it should display experiments started after 2018-05-27T18:25:43.511Z).

Please let me know when you manage this so that we can think of the frontend part. Thanks!

@Ori226
Copy link

Ori226 commented May 29, 2018

Thanks @chovanecm! I will try to go over this soon!

@chovanecm
Copy link
Owner Author

Hey @Ori226 ,
I am not sure if you managed to start working on the feature.
I have prepared a proof of concept, feel free to check it out. It is just something I tried to do during a single afternoon, so please don't expect it to be bulletproof. But it should (more or less) do the trick.

pip install https://github.com/chovanecm/sacredboard/archive/filter-by-date.zip

@Ori226
Copy link

Ori226 commented Aug 5, 2018

Hey @chovanecm , actually I prepared the environment and look at the code just a few days ago. I had several thoughts. I'lll probably get back to it only in a few weeks, but I'll try to look at what you did. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants