regro / regolith

Research Group Content Managment System
http://regro.github.io/regolith-docs/
Other
14 stars 69 forks source link

BUG: u_milestone #457

Closed dy2403 closed 4 years ago

dy2403 commented 4 years ago

problem with the due_date. loading ../db/projecta.yml... Traceback (most recent call last): File "/Users/danielayano/miniconda3/envs/regolith/bin/regolith", line 7, in exec(compile(f.read(), file, 'exec')) File "/Users/danielayano/dev/regolith/scripts/regolith", line 3, in main() File "/Users/danielayano/dev/regolith/regolith/main.py", line 337, in main CONNECTED_COMMANDSrc.cmd File "/Users/danielayano/dev/regolith/regolith/commands.py", line 150, in helper hlpr.hlp() File "/Users/danielayano/dev/regolith/regolith/helpers/basehelper.py", line 93, in hlp getattr(self, cmd)() File "/Users/danielayano/dev/regolith/regolith/helpers/u_milestonehelper.py", line 84, in db_updater all_milestones.sort(key=lambda x: x['due_date'], reverse=False) TypeError: '<' not supported between instances of 'datetime.date' and 'str'

sbillinge commented 4 years ago

did you try my code?

On Thu, Jun 18, 2020 at 12:18 PM dy2403 notifications@github.com wrote:

problem when the due_date in the db is a string. loading ../db/projecta.yml... Traceback (most recent call last): File "/Users/danielayano/miniconda3/envs/regolith/bin/regolith", line 7, in exec(compile(f.read(), file, 'exec')) File "/Users/danielayano/dev/regolith/scripts/regolith", line 3, in main() File "/Users/danielayano/dev/regolith/regolith/main.py", line 337, in main CONNECTED_COMMANDSrc.cmd http://rc File "/Users/danielayano/dev/regolith/regolith/commands.py", line 150, in helper hlpr.hlp() File "/Users/danielayano/dev/regolith/regolith/helpers/basehelper.py", line 93, in hlp getattr(self, cmd)() File "/Users/danielayano/dev/regolith/regolith/helpers/u_milestonehelper.py", line 84, in db_updater all_milestones.sort(key=lambda x: x['due_date'], reverse=False) TypeError: '<' not supported between instances of 'datetime.date' and 'str'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/regro/regolith/issues/457, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAOWUJX577MLI3DBMVAJZLRXI467ANCNFSM4OB5T3UA .

-- Professor Simon Billinge Columbia University

dy2403 commented 4 years ago

I am sorry @sbillinge , but which code?

sbillinge commented 4 years ago

I may be confused. I put a code snippet how to do the sort in a PR but it may not have been you.

On Thu, Jun 18, 2020 at 12:32 PM dy2403 notifications@github.com wrote:

I am sorry, which code?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/regro/regolith/issues/457#issuecomment-646148538, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAOWUPGJEBZDOLQFLXZUNTRXI6SDANCNFSM4OB5T3UA .

-- Professor Simon Billinge Columbia University

dy2403 commented 4 years ago

Oh ok, I am thinking in doing something like:

        for i in all_milestones:
            if isinstance(i['due_date'], str):
                i['due_date'] = dt.date.fromisoformat(i['due_date'])
        all_milestones.sort(key=lambda x: x['due_date'], reverse=False)
sbillinge commented 4 years ago

my idea won't work, but it looks like this:

all_milestones.sort(key=lambda x: get_dates{x}.get("date"), reverse=False)

if it was "begin_date" "date" or "end_date" it would work but we will have to work with "due_date"

On Thu, Jun 18, 2020 at 12:39 PM Simon Billinge sb2896@columbia.edu wrote:

I may be confused. I put a code snippet how to do the sort in a PR but it may not have been you.

On Thu, Jun 18, 2020 at 12:32 PM dy2403 notifications@github.com wrote:

I am sorry, which code?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/regro/regolith/issues/457#issuecomment-646148538, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAOWUPGJEBZDOLQFLXZUNTRXI6SDANCNFSM4OB5T3UA .

-- Professor Simon Billinge Columbia University

-- Professor Simon Billinge Columbia University

sbillinge commented 4 years ago

yes, this will work.

On Thu, Jun 18, 2020 at 12:42 PM dy2403 notifications@github.com wrote:

Oh ok, I am thinking in doing something like:

    for i in all_milestones:
        if isinstance(i['due_date'], str):
            i['due_date'] = dt.date.fromisoformat(i['due_date'])
    all_milestones.sort(key=lambda x: x['due_date'], reverse=False)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/regro/regolith/issues/457#issuecomment-646156674, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAOWUN7MRF6LX3JSW754OTRXI7WZANCNFSM4OB5T3UA .

-- Professor Simon Billinge Columbia University