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

relaxed click version #6801

Closed
wants to merge 1 commit into from
Closed

relaxed click version #6801

wants to merge 1 commit into from

Conversation

auvipy
Copy link
Member

@auvipy auvipy commented Jun 3, 2021

No description provided.

@codecov
Copy link

codecov bot commented Jun 3, 2021

Codecov Report

Merging #6801 (59cdf70) into master (799f839) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6801   +/-   ##
=======================================
  Coverage   70.69%   70.69%           
=======================================
  Files         138      138           
  Lines       16602    16602           
  Branches     2091     2091           
=======================================
  Hits        11737    11737           
  Misses       4669     4669           
  Partials      196      196           
Flag Coverage Δ
unittests 70.69% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 799f839...59cdf70. Read the comment docs.

@thedrow
Copy link
Member

thedrow commented Jun 6, 2021

Please hold off merging this as we're going to release 5.1.1 first once I finish up with a few patches.

@auvipy
Copy link
Member Author

auvipy commented Jun 6, 2021

ok

@auvipy auvipy requested a review from thedrow June 6, 2021 12:04
@mweinelt
Copy link

Calling the CLI with no args results in the following traceback with these relaxed dependencies on 5.1.1.

Traceback (most recent call last):
  File "/nix/store/2k70q69lvbhs1bmjvjgxj2paaxrqdwmi-python3.8-celery-5.1.1/bin/.celery-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/2k70q69lvbhs1bmjvjgxj2paaxrqdwmi-python3.8-celery-5.1.1/lib/python3.8/site-packages/celery/__main__.py", line 15, in main
    sys.exit(_main())
  File "/nix/store/2k70q69lvbhs1bmjvjgxj2paaxrqdwmi-python3.8-celery-5.1.1/lib/python3.8/site-packages/celery/bin/celery.py", line 213, in main
    return celery(auto_envvar_prefix="CELERY")
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1061, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 923, in make_context
    self.parse_args(ctx, args)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1624, in parse_args
    rest = super().parse_args(ctx, args)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1379, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 2364, in handle_parse_result
    value = self.process_value(ctx, value)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 2326, in process_value
    value = self.callback(ctx, self, value)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1279, in show_help
    echo(ctx.get_help(), color=ctx.color)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 704, in get_help
    return self.command.get_help(self)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1304, in get_help
    self.format_help(ctx, formatter)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1335, in format_help
    self.format_options(ctx, formatter)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1532, in format_options
    super().format_options(ctx, formatter)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 1355, in format_options
    rv = param.get_help_record(ctx)
  File "/nix/store/s6a73ssai10wpz50nnk2cy3k48wydl05-python3.8-click-8.0.1/lib/python3.8/site-packages/click/core.py", line 2727, in get_help_record
    default_value = self.get_default(ctx, call=False)
TypeError: get_default() got an unexpected keyword argument 'call'

@thedrow
Copy link
Member

thedrow commented Jun 23, 2021

@mweinelt Thanks for the heads up!
I'll investigate.

@frenzymadness
Copy link

I've tried to fix the issue. It seems that the get_default method in click now accepts also call keyword argument which the method in CeleryOption does not expect.

celery/celery/bin/base.py

Lines 141 to 144 in 82fe649

def get_default(self, ctx):
if self.default_value_from_context:
self.default = ctx.obj[self.default_value_from_context]
return super().get_default(ctx)

When I change it to:

    def get_default(self, ctx, **kwargs):
        if self.default_value_from_context:
            self.default = ctx.obj[self.default_value_from_context]
        return super().get_default(ctx, **kwargs)

It works fine. Could anybody try it or should I open a new PR?

@thedrow
Copy link
Member

thedrow commented Jun 30, 2021

I'll try it.

@ddevault
Copy link

It also seems that even correct usage causes apparently click-related issues:

[1:28:59] taiga ~/s/lists.sr.ht $ celery -A listssrht.process worker --loglevel INFO
Usage: celery worker [OPTIONS]
Try 'celery worker --help' for help.

Error: Invalid value for '-P' / '--pool': <class 'celery.concurrency.prefork.TaskPool'> is not one of 'prefork', 'eventlet', 'gevent', 'solo', 'processes', 'threads'.

Is anyone working on this? When celery gets out of sync with its dependencies, it makes it much harder to package it downstream.

@auvipy
Copy link
Member Author

auvipy commented Jul 17, 2021

I've tried to fix the issue. It seems that the get_default method in click now accepts also call keyword argument which the method in CeleryOption does not expect.

celery/celery/bin/base.py

Lines 141 to 144 in 82fe649

def get_default(self, ctx):
if self.default_value_from_context:
self.default = ctx.obj[self.default_value_from_context]
return super().get_default(ctx)

When I change it to:

    def get_default(self, ctx, **kwargs):
        if self.default_value_from_context:
            self.default = ctx.obj[self.default_value_from_context]
        return super().get_default(ctx, **kwargs)

It works fine. Could anybody try it or should I open a new PR?

you can come with a PR

@graingert
Copy link
Contributor

It also seems that even correct usage causes apparently click-related issues:

[1:28:59] taiga ~/s/lists.sr.ht $ celery -A listssrht.process worker --loglevel INFO
Usage: celery worker [OPTIONS]
Try 'celery worker --help' for help.

Error: Invalid value for '-P' / '--pool': <class 'celery.concurrency.prefork.TaskPool'> is not one of 'prefork', 'eventlet', 'gevent', 'solo', 'processes', 'threads'.

Is anyone working on this? When celery gets out of sync with its dependencies, it makes it much harder to package it downstream.

I'm looking at it now, here's the traceback for that:

Traceback (most recent call last):
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 1666, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 923, in make_context
    self.parse_args(ctx, args)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 1379, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 2364, in handle_parse_result
    value = self.process_value(ctx, value)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 2320, in process_value
    value = self.type_cast_value(ctx, value)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 2307, in type_cast_value
    return convert(value)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/types.py", line 75, in __call__
    return self.convert(value, param, ctx)
  File "/home/graingert/projects/celery/celery/bin/worker.py", line 48, in convert
    value = super().convert(value, param, ctx)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/types.py", line 288, in convert
    self.fail(
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/types.py", line 128, in fail
    raise BadParameter(message, ctx=ctx, param=param)
click.exceptions.BadParameter: <class 'celery.concurrency.prefork.TaskPool'> is not one of 'prefork', 'eventlet', 'gevent', 'solo', 'processes', 'threads'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/graingert/projects/celery/celery/bin/celery.py", line 214, in main
    return celery(auto_envvar_prefix="CELERY")
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/graingert/.virtualenvs/celery3/lib/python3.8/site-packages/click/core.py", line 1080, in main
    sys.exit(e.exit_code)
SystemExit: 2
(Pdb) 

@graingert
Copy link
Contributor

looks related to this change pallets/click@0c108f2

@graingert graingert mentioned this pull request Jul 19, 2021
@thedrow
Copy link
Member

thedrow commented Jul 20, 2021

I'm closing this as this was superseded by #6861.

@thedrow thedrow closed this Jul 20, 2021
@auvipy auvipy deleted the clik8 branch November 9, 2021 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants