Giter Site home page Giter Site logo

Comments (8)

Salamek avatar Salamek commented on June 1, 2024

Umm since when is full day name allowed in CRON expression? Allowed formats are 3 char name (MON) or int 0-6 i have never seen anyone use full name of a day...

from cron-descriptor.

Salamek avatar Salamek commented on June 1, 2024

Python-crontab is also using 3 char day names in it's docs...
https://pypi.org/project/python-crontab/

Looks like issue is in celery.schedules.crontab for some weir reason it accepts monday as valid day_of_week and then when it generates cron expression it generates invalid cron 0 2 monday * * correct format is 0 2 * * MON

from cron-descriptor.

nijel avatar nijel commented on June 1, 2024

Celery supports that (see referenced code). It might not be standard, though...

from cron-descriptor.

Salamek avatar Salamek commented on June 1, 2024

@nijel how i now wrote in previous comment, it is issue of celery.schedules.crontab and when it builds crontab string it passes incorrect value there...

from cron-descriptor.

Salamek avatar Salamek commented on June 1, 2024

celery.schedules,crontab should implement something like to_valid_cron():

c = crontab(hour=2, minute=0, day_of_week="monday")

# celery.schedules,crontab converts named days & months to their integer representation, use that instead!


minute, = c.minute
hour, = c.hour
day_of_week, = c.day_of_week

correct_cron = '{} {} {} {} {}'.format( 
    minute,
    hour,
    c._orig_day_of_month,
    c._orig_month_of_year,
    day_of_week
)
print(correct_cron)

Outputs 0 2 * * 1 that is valid cron

(this is put together to only work with your example parameters, do not use in production)

from cron-descriptor.

nijel avatar nijel commented on June 1, 2024

Yes, it might do a better job. But the way cron-descriptor crashed is not really helpful. I would not mind if it reported invalid input, but instead there is none exception message and the intermediate one contains something about 1DAY what has really nothing to do with the original string.

from cron-descriptor.

Salamek avatar Salamek commented on June 1, 2024

Hehe, this is not cron expression validator for sure... :-) Also that 1DAY is result of 'monday '.upper().replace('MON', '1') on line

expression_parts[5] = expression_parts[5].upper().replace(self._cron_days[day_number], str(day_number))

But i'll consider adding some kind of validation / better parsing exceptions...

from cron-descriptor.

Salamek avatar Salamek commented on June 1, 2024

(Should be) Fixed in downstream...

from cron-descriptor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.