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

[BUG] Error running tvm list command #66

Closed
felipemontoya opened this issue Mar 1, 2023 · 21 comments · Fixed by #68
Closed

[BUG] Error running tvm list command #66

felipemontoya opened this issue Mar 1, 2023 · 21 comments · Fixed by #68
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@felipemontoya
Copy link
Member

Describe the bug
When running tvm list the sorting function at https://github.com/eduNEXT/tvm/blob/main/tvm/cli.py#L145 fails because the local_versions are reported as v13.3.1@my-mango and this conflicts with the distutils.version.LooseVersion key.

To Reproduce
Steps to reproduce the behavior:
0. Have many installed versions of tutor.

  1. Run tvm list
  2. See error
Traceback (most recent call last):
  File "/home/fmo/.local/bin/tvm", line 8, in <module>
    sys.exit(main())
  File "/home/fmo/.local/lib/python3.10/site-packages/tvm/cli.py", line 40, in main
    cli()
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/fmo/.local/lib/python3.10/site-packages/tvm/cli.py", line 156, in list_versions
    version_names = sorted(version_names, reverse=False, key=LooseVersion)
  File "/usr/lib/python3.10/distutils/version.py", line 52, in __lt__
    c = self._cmp(other)
  File "/usr/lib/python3.10/distutils/version.py", line 341, in _cmp
    if self.version < other.version:
TypeError: '<' not supported between instances of 'str' and 'int'

Expected behavior
I would expect the list of available versions to show up.

Desktop (please complete the following information):

  • OS: linux mint 21.
  • Python 3.8 and 3.10
  • TVM Version: v2.2.0

Additional context
This is the current list of installations that I have and that fail.

v14.2.2@openai
v14.0.0@tutor
v13.3.1@tvm_env
v13.3.1
v14.0.0@tvm_env
v12.2.0 (active)
v13.2.2
v14.2.2@2022_dec
v12.2.0@openai
v13.0.0@dd_tutor
v13.2.2@GqTXDukMmd
v14.0.0
v12.2.0@nau-lilac
v13.3.1@my-mango
v13.0.0
v14.0.0@tutor2
@felipemontoya felipemontoya added bug Something isn't working help wanted Extra attention is needed labels Mar 1, 2023
@felipemontoya
Copy link
Member Author

In version 3.10 of python distutils is deprecated and should be changed to packaging.version. However doing so would yield

Traceback (most recent call last):
  File "/home/fmo/.local/bin/tvm", line 8, in <module>
    sys.exit(main())
  File "/home/fmo/.local/lib/python3.10/site-packages/tvm/cli.py", line 40, in main
    cli()
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/fmo/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/fmo/.local/lib/python3.10/site-packages/tvm/cli.py", line 156, in list_versions
    version_names = sorted(version_names, reverse=False, key=LooseVersion)
  File "/usr/lib/python3/dist-packages/packaging/version.py", line 266, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: 'v14.0.0@tvm_env'

@JuanDavidBuitrago JuanDavidBuitrago changed the title [BUG] [BUG] Error running tvm list command Mar 1, 2023
@JuanDavidBuitrago
Copy link
Member

Hi @felipemontoya,

Thank you for reporting this, we will take it into account to be included in the next sprint that starts on March 6, to be analyzed. If you have any additional comments, feel free to post.

@Alec4r
Copy link
Member

Alec4r commented Mar 10, 2023

Ey @felipemontoya I'm working on fix this, but I could not replicate the error:

I tested in:
OS: Mac OS 13.
Python 3.9.6 and 3.10.9
TVM Version: v2.2.0 (Master and Tag)

OS: Ubuntu 22.04
Python 3.10.6
TVM Version: v2.2.0 (Master and Tag)

Also, I created some projects:

  • v15.1.0@my-project
  • v15.0.0@survey_report
  • v15.1.0@olmo

and I don't have problems when I run the command "tvm list".

@Alec4r
Copy link
Member

Alec4r commented Mar 10, 2023

@felipemontoya Let me know if you still have problems with this, and if you have more information to I try replicate the error.

@felipemontoya
Copy link
Member Author

I know that to solve it, what I did was comment out this line:
https://github.com/eduNEXT/tvm/blob/main/tvm/cli.py#L145

Something about LooseVersion did not want to compare strings to numbers.

We could wrap the line in a try-catch to fix it.

@felipemontoya
Copy link
Member Author

However in order to reach that I kinda messed up my dependencies. In the process of fixing that I decided I would rather udpate my linux and delete the ~/.tvm dir.

@Alec4r
Copy link
Member

Alec4r commented Mar 10, 2023

I don't want to add an try except just for an isolated case, maybe is just a dependency in your computer so I want to find what is the real problem and not apply a hot fix.

I know that to solve it, what I did was comment out this line: https://github.com/eduNEXT/tvm/blob/main/tvm/cli.py#L145

Something about LooseVersion did not want to compare strings to numbers.

We could wrap the line in a try-catch to fix it.

@felipemontoya
Copy link
Member Author

Absolutly. The try catch should be only if we can reproduce the error.

@Alec4r could you run one last test.

try to create a project named with a number. I think the v14.2.2@2022_dec might have been the issue. You can take it to the next level by using a number only.

@felipemontoya
Copy link
Member Author

It works! I mean, it fails!

Steps to reproduce:

tvm project init 2023 v15.3.1
tvm list

@Alec4r
Copy link
Member

Alec4r commented Mar 10, 2023

Absolutly. The try catch should be only if we can reproduce the error.

@Alec4r could you run one last test.

try to create a project named with a number. I think the v14.2.2@2022_dec might have been the issue. You can take it to the next level by using a number only.

I tested in:
OS: Mac OS 13.
Python 3.9.6
TVM Version: v2.2.0 (Master)

with this command tvm project init 2022_dec v14.2.2

and I don't have problems

v14.2.2 (active)
v14.2.2@2022_dec
v14.2.3
v15.0.0
v15.0.0@survey_report
v15.1.0
v15.1.0@my-mango
v15.1.0@olmo

@felipemontoya
Copy link
Member Author

And its fixed again with sudo rm -r ~/.tvm/v15.3.1@2023/

@Alec4r
Copy link
Member

Alec4r commented Mar 10, 2023

It works! I mean, it fails!

I tested in:
OS: Mac OS 13.
Python 3.9.6
TVM Version: v2.2.0 (Master)

with this command tvm project init 2023 v15.3.1

and I don't have problems

v14.2.2
v14.2.2@2022_dec
v14.2.3
v15.0.0
v15.0.0@survey_report
v15.1.0
v15.1.0@my-mango
v15.1.0@olmo
v15.2.0
v15.3.0
v15.3.1 (active)
v15.3.1@2023

@felipemontoya
Copy link
Member Author

and I don't have problems

Oh wow.

Im running:

$ python3 --version
Python 3.10.6

$ tvm --version
tvm, version 2.2.0

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 21
Release:	21
Codename:	vanessa

@MaferMazu
Copy link
Contributor

I can't replicate this error.
I'm using Python 3.10.6, TVM 2.2.0, Ubuntu 22.04.2, python3-distutils version 3.10.6-1~22.04, and packaging 21.3 (and I tried with packaging 23.0)
There is something with the packages, but I don't know how to fix this.

@MaferMazu
Copy link
Contributor

I don't know what happened these previous two weeks, but the tvm list fails me with the same Felipe's error.

Traceback (most recent call last):
  File "/home/edunext/.local/bin/tvm", line 8, in <module>
    sys.exit(main())
  File "/home/edunext/.local/lib/python3.10/site-packages/tvm/cli.py", line 40, in main
    cli()
  File "/home/edunext/.local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/edunext/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/edunext/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/edunext/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/edunext/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/edunext/.local/lib/python3.10/site-packages/tvm/cli.py", line 145, in list_versions
    version_names = sorted(version_names, reverse=False, key=LooseVersion)
  File "/usr/lib/python3.10/distutils/version.py", line 52, in __lt__
    c = self._cmp(other)
  File "/usr/lib/python3.10/distutils/version.py", line 341, in _cmp
    if self.version < other.version:
TypeError: '<' not supported between instances of 'int' and 'str'

@JuanDavidBuitrago
Copy link
Member

I created a Jira card to check this again. Link: https://edunext.atlassian.net/browse/DS-503

@Alec4r
Copy link
Member

Alec4r commented May 10, 2023

@felipemontoya @MaferMazu thanks, we are planning add this to our next sprint, so I hope have good news for you soon.

@MaferMazu
Copy link
Contributor

I formatted my computer, and I can't replicate this error anymore.

Right now works well, and I have:

  • Python3.10
  • Click v8.0.3
  • Distutils v3.10.6
  • Setuptools v59.6.0

Interesting note: starting from Python 3.10, distutils has been declared as deprecated in favor of setuptools.

@Asespinel
Copy link

I have replicated the error mentioned in this issue on my local environment. Here are the details of my environment settings:

  • Python 3.8
  • tvm 2.20
  • Ubuntu 20.04 LTS
  • Shell: Zsh

Error details

  1. Create a project with only numbers as a name:
    tvm project init 2023 v15.0.0
  2. Use tvm list
  3. Output:
Traceback (most recent call last):
  File "/home/andres/.local/bin/tvm", line 8, in <module>
    sys.exit(main())
  File "/home/andres/.local/lib/python3.8/site-packages/tvm/cli.py", line 40, in main
    cli()
  File "/home/andres/.local/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/andres/.local/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/andres/.local/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/andres/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/andres/.local/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/andres/.local/lib/python3.8/site-packages/tvm/cli.py", line 145, in list_versions
    version_names = sorted(version_names, reverse=False, key=LooseVersion)
  File "/usr/lib/python3.8/distutils/version.py", line 52, in __lt__
    c = self._cmp(other)
  File "/usr/lib/python3.8/distutils/version.py", line 337, in _cmp
    if self.version < other.version:
TypeError: '<' not supported between instances of 'int' and 'str'

Note: I previously created a project named '2023-test' with the same tutor version, and I had no issues

@rediris
Copy link

rediris commented Feb 9, 2024

Still an issue in in 2.2.0:

Traceback (most recent call last):
  File "/some/home/directory/.p3/bin/tvm", line 8, in <module>
    sys.exit(main())
  File "/some/home/directory/.p3/lib/python3.9/site-packages/tvm/cli.py", line 40, in main
    cli()
  File "/some/home/directory/.p3/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/some/home/directory/.p3/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/some/home/directory/.p3/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/some/home/directory/.p3/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/some/home/directory/.p3/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/some/home/directory/.p3/lib/python3.9/site-packages/tvm/cli.py", line 145, in list_versions
    version_names = sorted(version_names, reverse=False, key=LooseVersion)
  File "/some/home/directory/.p3/lib/python3.9/site-packages/setuptools/_distutils/version.py", line 72, in __lt__
    c = self._cmp(other)
  File "/some/home/directory/.p3/lib/python3.9/site-packages/setuptools/_distutils/version.py", line 351, in _cmp
    if self.version < other.version:
TypeError: '<' not supported between instances of 'int' and 'str'

@MaferMazu MaferMazu linked a pull request Apr 17, 2024 that will close this issue
@bra-i-am
Copy link
Contributor

hey, I hope you all are doing great.

I am passing here (sorry for the delay) to inform you that this issue was addressed and the solution involved two main changes:

  1. It was removed the dependency distutils (which is going to be deprecated in future Python releases) in favor of packaging.version.
  2. It was necessary to modify a sorter function taking into account the proper way of implementing local version labels to allow that packaging.version takes the version names properly for creating the Version objects that will be compared for sorting

If you would like more details, please go to the changes applied with PR #68.

Thank you ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants