chovanecm / sacredboard

Dashboard for sacred. Monitor and access your past machine learning experiments.
MIT License
184 stars 39 forks source link

Filtering on experiments: Date #35

Open chovanecm opened 7 years ago

chovanecm commented 7 years ago

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.

Ori226 commented 6 years ago

Any progress?

chovanecm commented 6 years ago

Not from my side.

Ori226 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

chovanecm commented 6 years ago

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 commented 6 years ago

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