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

Add support for part query from TME #164

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

spike77453
Copy link
Contributor

This adds support for part query from TME (Transfer Multisort Elektronik: https://www.tme.eu, headquartered in Poland).

kintree/search/tme_api.py is taken directly from #115. I hope @martonmiklos doesn't mind.

I'm not entirely sure how to handle the dependency on https://github.com/krzych82/api-client-python3 here:
https://github.com/sparkmicro/Ki-nTree/compare/main...spike77453:Ki-nTree:feature_tme_support?expand=1#diff-b2540e137995506e90ad635a1dbee24c1017fae8e8ade9e7da60628af46da9f8R6
Upstream neither provides a pypi release nor a seutp.py or pyproject.toml so it cannot be easily installed via pip, etc.

Feedback, pointers, and suggestions are welcome.

@spike77453 spike77453 marked this pull request as draft July 2, 2023 15:59
@martonmiklos
Copy link
Contributor

kintree/search/tme_api.py is taken directly from #115. I hope @martonmiklos doesn't mind.

I am very glad to see this PR. I am stuck with tow broken and casted forearms, so I am grateful that you work on this.

Upstream neither provides a pypi release nor a seutp.py or pyproject.toml so it cannot be easily installed via pip, etc.

Feedback, pointers, and suggestions are welcome.

I would simply add this as a submodule.

@spike77453
Copy link
Contributor Author

kintree/search/tme_api.py is taken directly from #115. I hope @martonmiklos doesn't mind.

I am very glad to see this PR. I am stuck with tow broken and casted forearms, so I am grateful that you work on this.

Oh no. Get well soon!

Upstream neither provides a pypi release nor a seutp.py or pyproject.toml so it cannot be easily installed via pip, etc.
Feedback, pointers, and suggestions are welcome.

I would simply add this as a submodule.

Works for me. I've added it as a submodule.
Just wasn't sure if that integrates well with the poetry build. There's also not license mentioned upstream (https://github.com/krzych82/api-client-python3) so as far as I'm aware that implies all rights are reserved.

@spike77453 spike77453 marked this pull request as ready for review July 2, 2023 20:37
@eeintech
Copy link
Contributor

eeintech commented Jul 4, 2023

Thanks @spike77453 I will need to review this PR soon, in the meantime do you mind fixing the style?

@spike77453 spike77453 force-pushed the feature_tme_support branch 2 times, most recently from 41cc23e to ee135d8 Compare July 4, 2023 14:23
@spike77453
Copy link
Contributor Author

spike77453 commented Jul 4, 2023

in the meantime do you mind fixing the style?

Sure thing! Style checks should now pass.

@spike77453 spike77453 force-pushed the feature_tme_support branch 3 times, most recently from c492004 to e102f80 Compare July 5, 2023 00:29
@eeintech
Copy link
Contributor

eeintech commented Jul 6, 2023

Thanks for fixing the style.

Two things:

  1. I cannot run the GUI anymore, I'm getting the same import error as in the CI:
$ python -m kintree_gui
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/francois/development/Ki-nTree/kintree_gui.py", line 2, in <module>
    from kintree.kintree_gui import main
  File "/home/francois/development/Ki-nTree/kintree/kintree_gui.py", line 3, in <module>
    from .gui.gui import kintree_gui
  File "/home/francois/development/Ki-nTree/kintree/gui/gui.py", line 4, in <module>
    from .views.main import (
  File "/home/francois/development/Ki-nTree/kintree/gui/views/main.py", line 19, in <module>
    from ...database import inventree_interface
  File "/home/francois/development/Ki-nTree/kintree/database/inventree_interface.py", line 8, in <module>
    from ..search import search_api, digikey_api, mouser_api, element14_api, lcsc_api, tme_api
  File "/home/francois/development/Ki-nTree/kintree/search/tme_api.py", line 3, in <module>
    from .tme.tmeapi import Client
ModuleNotFoundError: No module named 'kintree.search.tme.tmeapi'
  1. I have looked into the submodule you'd like to use and everything is very generic code/project name and there is no license on this project... Can you ask the maintainer if we can port his code into Ki-nTree instead of adding it as submodule? Else we can also develop the same code, it is very simple.

@spike77453
Copy link
Contributor Author

I cannot run the GUI anymore, I'm getting the same import error as in the CI:

Did you initialise the submodule or clone the branch with --recurse-submodules, e.g.

git clone --recurse-submodules --branch feature_tme_support https://github.com/spike77453/Ki-nTree/

That should work just fine.

I have looked into the submodule you'd like to use and everything is very generic code/project name and there is no license on this project... Can you ask the maintainer if we can port his code into Ki-nTree instead of adding it as submodule? Else we can also develop the same code, it is very simple.

I'll open an issue at https://github.com/krzych82/api-client-python3 and ask.
It also does some nasty things: https://github.com/sparkmicro/Ki-nTree/pull/164/files#diff-b2540e137995506e90ad635a1dbee24c1017fae8e8ade9e7da60628af46da9f8R50-R52 so I'm not all opposed to writing something similar.

@eeintech
Copy link
Contributor

eeintech commented Aug 9, 2023

@spike77453 Following up on that, did you ask the owner of the package if it's fine to use his code and/or rewrite it?

@martonmiklos
Copy link
Contributor

@spike77453 Following up on that, did you ask the owner of the package if it's fine to use his code and/or rewrite it?

Request had been made:
krzych82/api-client-python3#3
however @krzych82 have not responded yet.

However it seems that there is a code with similar functionality in this repo which has proper licensing:
https://github.com/tme-dev/TME-API/blob/master/Python/call.py

Maybe it would be easier to port to this?

@krzych82
Copy link

krzych82 commented Aug 9, 2023

Hi.
License added. You can feel free to use and rewrite it.

@eeintech
Copy link
Contributor

eeintech commented Aug 10, 2023

Thanks @krzych82 👍

@spike77453 Can you please pull the main branch in, then I'll rerun the CI 👍

@spike77453 spike77453 force-pushed the feature_tme_support branch 2 times, most recently from ebd5a7b to 90b0451 Compare August 11, 2023 00:02
@spike77453
Copy link
Contributor Author

spike77453 commented Aug 11, 2023

@spike77453 Can you please pull the main branch in, then I'll rerun the CI 👍

@eeintech I've updated the submodule to its remote master (to include the license file) and rebased this feature branch to main. Let me know if that works for you.

Since https://github.com/krzych82/api-client-python3/ was licensed under GPLv3.0 is should be permissible to just copy tmeapi.py into kintree/search/tme/ without using a git submodule, if you prefer.

@eeintech
Copy link
Contributor

@spike77453 The GUI is still failing to run, try to store the file inside the project in in this case? I'd rather that option than a submodule. Thanks!

@spike77453 spike77453 force-pushed the feature_tme_support branch 2 times, most recently from 104b1d0 to 3443c77 Compare August 12, 2023 21:42
@spike77453
Copy link
Contributor Author

I've opted to reimplement the functionality of https://github.com/krzych82/api-client-python3. The API examples/snippets TME give in their documentation are MIT licensed (https://github.com/tme-dev/TME-API/blob/master/Python/call.py) so that should be fine.

Hope that works for you.

@spike77453 spike77453 force-pushed the feature_tme_support branch 2 times, most recently from 327debe to e8a20dd Compare August 12, 2023 22:03
@eeintech
Copy link
Contributor

@spike77453 Works for me! There still is an error in the CI:

Traceback (most recent call last):
  File "/home/runner/work/Ki-nTree/Ki-nTree/kintree_gui.py", line 2, in <module>
    from kintree.kintree_gui import main
  File "/home/runner/work/Ki-nTree/Ki-nTree/kintree/kintree_gui.py", line 3, in <module>
    from .gui.gui import kintree_gui
  File "/home/runner/work/Ki-nTree/Ki-nTree/kintree/gui/gui.py", line 10, in <module>
    from .views.settings import (
  File "/home/runner/work/Ki-nTree/Ki-nTree/kintree/gui/views/settings.py", line 87, in <module>
    tme_api_settings['TME_API_TOKEN'],
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
Error: Process completed with exit code 1.

@spike77453
Copy link
Contributor Author

I'm afraid that's nothing I can fix. You'd have to specify an API token, probably via an encrypted secret: https://github.com/sparkmicro/Ki-nTree/blob/main/.github/workflows/test_deploy.yaml#L43-L53

@eeintech
Copy link
Contributor

@spike77453 I think the right syntax would be: tme_api_settings.get('TME_API_TOKEN', '') and same for others

@spike77453
Copy link
Contributor Author

My bad! I added default configuration files but forgot to load them in: https://github.com/sparkmicro/Ki-nTree/compare/e8a20dd8c7caa95673c3ec8da173892d0752275d..822f0ef1703c47081e062c83bb781e718e1de302
Should be ok now.

@eeintech eeintech merged commit 7af315a into sparkmicro:main Aug 16, 2023
9 checks passed
@eeintech
Copy link
Contributor

Great, thanks @spike77453 I'll prepare a new release

@eeintech eeintech mentioned this pull request Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants