panoptes-organization / monitor-schema

MIT License
3 stars 4 forks source link

What is the format of the timestamps? #4

Open vsoch opened 3 years ago

vsoch commented 3 years ago

It looks like several of the Workflow fields return a timestamp in the json, and I don't see specific formatting so I think with flask's jsonify it might come out like this

with app.app_context():
    ...:     print(jsonify({"time": datetime.now()}).json)
    ...: 
    ...: 
{'time': 'Tue, 15 Dec 2020 11:38:48 GMT'}

Should there be a more common / standard datetime format here? It looks like snakemake uses a sort of flattened version:

datetime.now().strftime("%Y%m%d%H%M.%S")
# '202012151141.49'

And more standard would be something like:

datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# '2020-12-15 11:40:48'

or even if we just print it (is this what the flask app currently does?

print(datetime.now())
2020-12-15 11:43:24.811860
fgypas commented 3 years ago

I think we should have a consistent timestamp (ideally the same as snakemake does). The only thing I would propose/choose something compatible with humanfriendly.

vsoch commented 3 years ago

I was actually going to suggest that we look through dependencies and remove those that aren't essential, humanfriendly was one that caught my eye because it's used just once:

$ grep -R humanfriendly
app.py:import humanfriendly
app.py:    return humanfriendly.format_timespan(value)

And we could achieve the same with just a regular expression. Would you be open to an issue that looks through current dependencies and sees if we can slim down the set?

vsoch commented 3 years ago

It looks like you have a function to format the timestamp in a view, another option

def format_datetime(value, format="%d %b %Y %I:%M %p"):
   ...

Although I do think the human friendly timestamp to show in a web interface should be different than the one used programatically (the first optimized for human readability, the latter for machine).

fgypas commented 3 years ago

@gkostoulas Any opinion on this? It relates to https://github.com/panoptes-organization/panoptes/issues/79

fgypas commented 3 years ago

@vsoch I think that the timestamps that you chose are fine.