fohrloop / dash-uploader

The alternative upload component for python Dash applications.
MIT License
144 stars 30 forks source link

AttributeError: module 'packaging.version' has no attribute 'LegacyVersion' #111

Closed meghna200 closed 3 weeks ago

meghna200 commented 1 year ago

I have hosted my dash app on AWS using a DockerFile. While trying to deploy the app, I am getting an error which I am guessing is with the dash_uploader component

the error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
    mod = importlib.import_module(module)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/docker-test/src/main.py", line 41, in <module>
    from modules.pydash_components.pages.main_pages.data_page.data_load import data_load_layout
  File "/docker-test/src/modules/pydash_components/pages/main_pages/data_page/data_load.py", line 169, in <module>
    def callback_on_completion(status: du.UploadStatus):
  File "/usr/local/lib/python3.9/site-packages/dash_uploader/callbacks.py", line 105, in add_callback
    if dash_version_is_at_least("1.12"):
  File "/usr/local/lib/python3.9/site-packages/dash_uploader/utils.py", line 20, in dash_version_is_at_least
    if isinstance(dash_version, version.LegacyVersion):
AttributeError: module 'packaging.version' has no attribute 'LegacyVersion'

I am using the following dash versions:

python==3.9.12
dash==2.7.0
dash_bootstrap_components==1.0.3
dash_extensions==0.1.7
dash_table==5.0.0
dash_uploader==0.7.0a1

any idea how I can resolve this without deprecating any packages?

wayneconnolly commented 1 year ago

I have this issue also.

python==3.9.13
dash==2.7.0
dash-bootstrap-components==1.1.0
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-renderer==1.9.1
dash-table==5.0.0
dash-uploader==0.7.0a1
wayneconnolly commented 1 year ago

I solved this via a hotfix.

I commented out lines 20 and 21 of:

https://github.com/np-8/dash-uploader/blob/dev/dash_uploader/utils.py

meghna200 commented 1 year ago

I solved this issue by adding packages==21.0.0 in my requirements.txt file. the app seems to run without the issue showing up again

valentindusollier commented 1 year ago

Yes indeed. In the last version of packaging (version 22.0), LegacyVersion was removed see changelog. So the temporary solution of @meghna200 is the right way to handle it now. Note that the most recent version except 22.0 is 21.3

wayneconnolly commented 1 year ago

packages==21.0.0

ERROR: Could not find a version that satisfies the requirement packages==21.0.0 (from versions: 0.1.0)

There is only 0.1.0 https://pypi.org/project/packages/#history

It's actually packaging==21.3.0. That's the latest version to work as stated by @valentindusollier

mapix commented 11 months ago

Thanks to @Sisyphus235 's contribution, this issue will be fixed in the next version release.

Ref https://github.com/fohrloop/dash-uploader/pull/128

GitHunter0 commented 5 months ago

Hi folks @mapix , @fohrloop , do you have a planned release date for the next version?

I'm asking because fixing packages==21.0.0 is preventing the installation of other important packages...

fohrloop commented 4 months ago

@GitHunter0 I'm not actively working on this project and not planning to use time on this in the near future. This project is looking for maintainers so if anyone is able to make fixes, please raise your hand and I'll add you the required privileges to make merges. I'm the only one with PyPI upload rights, but I'm able to help if there's a release to be made. In the long run, also those rights should be transferred / shared but that requires a longer time effort or trust gained otherwise.

fohrloop commented 4 months ago

@mapix what do you think, are you able to use some time for a new release? or others on this thread?

GitHunter0 commented 4 months ago

Thank you for the feedback, @fohrloop . That would be really great if @mapix could update this package. It is an important component, so much better than the native Dash uploader...

mapix commented 4 months ago

@fohrloop Yes , Could you please help add the release permissions on PyPI? I am currently unable to publish. mapix or mapix.me@gmail.com on pypi

fohrloop commented 4 months ago

@mapix I appreciate that you would like to volunteer here and help. What I meant by "being able to use some time for a new release" was the ability to work on the project so there's something to be released :) I can still for some time keep the responsibility to upload a new packaged release to PyPI. Quoting my message above:

In the long run, also those rights should be transferred / shared but that requires a longer time effort or trust gained otherwise.

And the reason for this is that there have been some supply chain attacks in the open source projects in the past, so I think it's good practice to share the publishing rights sparingly. I hope you understand that.

Do you think there are changes in the dash-uploader repo already which should be packaged and published..?

mapix commented 4 months ago

@fohrloop Understood. I have gathered some necessary information. We can track it at https://github.com/fohrloop/dash-uploader/pull/135 .

gcroci2 commented 3 months ago

I also encountered this issue. It seems fixed by installing packaging==21.3.0 as others suggested, but looking forward to the official fix.

simonlet commented 1 month ago

Is it possible to release a 0.6.1 version where the LegacyVersion check is removed from callbacks.py? The newer packaging library no longer includes it, and downgrading packaging causes issues in my setup.

fohrloop commented 1 month ago

I can upload a new version (0.6.1 or 0.7.0) to PyPI if someone has time to create one.

simonlet commented 1 month ago

I forked the stable branch and removed the LegacyVersion check, but I do not know how to build the package. Can you help me with that? Thanks!

fohrloop commented 4 weeks ago

@simonlet Great! The CONTRIBUTING.md has some instructions. I hope they're still valid!

simonlet commented 3 weeks ago

So I ran the following commands:

  1. npm install
  2. npm run build
  3. npm audit fix
  4. python -m pip install -e .[dev]
  5. python ./setup.py sdist This gave me this file: dash_uploader-0.6.1.tar.gz Let me know, if this works fine!
fohrloop commented 3 weeks ago

@simonlet great to hear you got it working! Could you please make a PR against dev? I could publish it as version 0.7.0.

simonlet commented 3 weeks ago

I suppose, you meant the stable branch, because on dev the problem is already fixed. Sure, I can do that!

fohrloop commented 3 weeks ago

Thanks! Merged. I'm trying to build it but running into bunch of issues. Most likely some versions were not pinned and now something is not anymore compatible with the rest of the requirements. Which npm version you used? I'm using 10.8.2.

fohrloop commented 3 weeks ago

Ok, got npm install working by downgrading webpack from "5.29" to "^4.29".

Ran: npm install, got: 58 vulnerabilities (1 low, 20 moderate, 32 high, 5 critical) Ran: npm audit fix, got: 40 vulnerabilities (1 low, 15 moderate, 23 high, 1 critical) Ran: npm run build and python ./setup.py sdist and got the dist/dash_uploader-0.6.1.tar.gz

fohrloop commented 3 weeks ago

dash-uploader 0.6.1 uploaded to PyPI. Please @simonlet or others, could someone test if it's working for you?

simonlet commented 3 weeks ago

It is working for me! 👍

fohrloop commented 3 weeks ago

That's great! I think since this is fixed in both, 0.6.x (stable) and 0.7.x (dev), this one can finally be closed. Thanks a lot for the help!

GitHunter0 commented 3 weeks ago

Hi folks @fohrloop , @simonlet , I'm receiving AttributeError: module 'dash_uploader' has no attribute 'UploadStatus'.

EDIT: this is because I used version 0.6.1. Will version 0.7.1 be released too? Thank you for the efforts.

simonlet commented 3 weeks ago

The UploadStatus class is only part of the dev branch, which only the pre-release version 0.7.0a1 seems to be based on. Version 0.6.1 is based on the stable branch, so you can not use UploadStatus unfortunately.

GitHunter0 commented 3 weeks ago

I realized that @simonlet , thank you for the feedback. Any plans on releasing version 0.7.1? UploadStatus is necessary in my project...

fohrloop commented 3 weeks ago

@GitHunter0 Based on this comment I interpreted that the LegacyVersion related problem is fixed on 0.7.0a1, too. What is the problem you're facing?

GitHunter0 commented 3 weeks ago

@GitHunter0 Based on this comment I interpreted that the LegacyVersion related problem is fixed on 0.7.0a1, too

@fohrloop , I reinstalled 0.7.0a1 without packaging==21.3.0 and received AttributeError: module 'packaging.version' has no attribute 'LegacyVersion'

simonlet commented 3 weeks ago

Sorry, I was only looking at the dev branch, where the LegacyVersion check was already fixed. It was removed in this pull request #128. I suppose, version 0.7.0a1 was created before the pull request was merged.

fohrloop commented 3 weeks ago

No problem. @GitHunter0 I just released the changes as version 0.7.0-a2. You may install it with the --pre flag from PyPI. Let me hear if it works for you. If so, I might as well publish it as the 0.7.0.

GitHunter0 commented 3 weeks ago

Awesome, I appreciate @fohrloop , version 0.7.0-a2 seems to be working fine here.