'upgrading celery 4.x.x to 5.x.x in Django app - execute_from_commandline() replacement

the usage in 4.x.x was as following:

from tenant_schemas_celery.app import CeleryApp

class TenantCeleryApp(CeleryApp):
    def create_task_cls(self):
        return self.subclass_with_self('...', abstract=True, name='...', attribute='_app')

tenant_celery = TenantCeleryApp()
base = celery.CeleryCommand(app=tenant_celery)
base.execute_from_commandline('...')
...

Now when updating celery lib to 5.x.x the following error show:

base = celery.CeleryCommand(app=tenant_celery) 
TypeError: __init__() got an unexpected keyword argument 'app'

from the documentation, the new CeleryCommand use click.Command class, how do I change my code to fit - what is the replacement usage for execute_from_commandline()?

EDIT: after some tries hard the following code works:

tenant_celery.worker_main(argv=['--broker=amqp://***:***@rabbitmq:5672//***',
                                    '-A', f'{__name__}:tenant_celery',
                                    'worker', '-c', '1', '-Q', 'c1,c2,c3,c4'])


Solution 1:[1]

Your logic works fine expect for the margin on top and that's because you have used a fixed value when it should be a relative one as percentage. Changing the margin of test to margin-top:6%; seems to work better. You can fine tune it by editing the image to fit your needs as well I guess.

Solution 2:[2]

Went with an approach incorporating vw. To start, my background image fits into .entry-content at 100%. The .tableContainer is sized at 75% to match the background image table. Used 75vw. Then got the aspect ratio of the image to set the height of the container. Also used a media query to set a max width and height...

.entry-content {
      background-image: url("https://i.postimg.cc/R0rR2qmp/bg-report-test-1500x2023.png");
      /* image aspect ratio is 1.349 */
      background-size: 100% auto;
      background-repeat: no-repeat;
      margin: 0 0 0 0;
      height: calc(100vw*1.349);
      max-width: 1200px; /* from wordpress */
    }
.tableContainer {
      padding: 0 0 0 0;
      width: 75vw;
      height: calc(75vw*1.349);
      margin-top: 6%;
    }
@media only screen and (min-width: 1200px) {
    .container-fluid.test {
        width: 900px;
        height: calc(1200px*1.349)
    }
}

From there I determined the heights of the table rows using either a fixed pixel height for the max size or vw when the window is smaller...

.test tr {
    height: 48.96px
}
@media only screen and (max-width: 1200px) {
    /* When 100 vw = 1200px; 100 vh = 1200px * 1.349 = 1618.8px; */
    /* When 100vw, table is 75vw 75vh */
    /* 48.96/1200 = 0.0408 */
    /* 4.08vw doesn't work so use an eyeball number */
    .test tr { height: 3.75vw; }
    ...

It's maybe a weird solution. Gonna sit with it for a bit before I decide it's an answer answer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maria Nirmal
Solution 2 markw