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

Is it possible to skip or add a nice message to the user when trying to access services like Kitspace? #417

Open
leoheck opened this issue Jun 9, 2020 · 16 comments
Labels
enhancement Improvements on features already existent.

Comments

@leoheck
Copy link

leoheck commented Jun 9, 2020

Using v1.1.5

# Getting part data from KitSpace...
Starting new HTTPS connection (1): dev-partinfo.kitspace.org:443                                                                              
https://dev-partinfo.kitspace.org:443 "POST /graphql HTTP/1.1" 504 192                                                                        
Progress:   0%|                                                                                                      | 0/52 [01:01<?, ?part/s]Traceback (most recent call last):
  File "/usr/local/bin/kicost", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/kicost/__main__.py", line 306, in main
    kicost(in_file=args.input, eda_name=args.eda,
  File "/usr/local/lib/python3.8/dist-packages/kicost/kicost.py", line 251, in kicost
    api_partinfo_kitspace.query_part_info(parts, distributor_dict, currency)
  File "/usr/local/lib/python3.8/dist-packages/kicost/distributors/api_partinfo_kitspace.py", line 366, in query_part_info
    get_part_info(queries[slc], query_parts[slc], query_part_stock_code[slc])
  File "/usr/local/lib/python3.8/dist-packages/kicost/distributors/api_partinfo_kitspace.py", line 208, in get_part_info
    results = api_partinfo_kitspace.query(query, distributors)
  File "/usr/local/lib/python3.8/dist-packages/kicost/distributors/api_partinfo_kitspace.py", line 146, in query
    raise Exception('One of the internal Kitspace services may experiencing problems. Contact the Kitspace support.')
Exception: One of the internal Kitspace services may experiencing problems. Contact the Kitspace support.
Progress:   0%|                                                                                                      | 0/52 [01:01<?, ?part/s]
@leoheck
Copy link
Author

leoheck commented Jun 9, 2020

I cant use the GUI, so, does kicost has any flag to help here?

@mdeweerd
Copy link
Contributor

I always run with --debug 10 to get some hint at which part is failing.

The number of requests to Kitspace is shared amongst the users.
Therefor, I also recommend using --no_price while you are cleaning up your BOM and check prices only later when you are confident that you part numbers and variants are correctly set up.

@leoheck
Copy link
Author

leoheck commented Jun 10, 2020

So let me understand this better. I can't run this many times in a short period of time because of the limitations of the service itself. So, a user-friendly message saying the server wont handle more requests would be nice when running this tool, instead of just trying forever and dying at the end.

I always run with --debug 10 to get some hint at which part is failing.

Cool, thanks. I was testing this flag yesterday to go over the issue and it helped to at least find and debug my setup.

Also, I am thinking here since this tool is so dependable of the requests, why not do the other way around where the default is to be no_price and then the user has to use the flag --price to actually request these prices to the server?

@leoheck leoheck changed the title Is it possible skip instead of break when a url is not working? Is it possible to skip or add a nice message to the user when trying to access services like Kitspace? Jun 10, 2020
@hildogjr
Copy link
Owner

hildogjr commented Jun 10, 2020

Yes, we need some code revision for warning and error messages. I did some in past but stil missing a lot.

KiCost emerged a cost tool the --no_price was a feature add after so users that just want the part list of the BOM.

@mdeweerd
Copy link
Contributor

I understand that the core of the kicost tool is pricing, but at the same time I think it is wise to lmiit resource usage.
So actually requiring "--price" as an option doesn't seem like a bad idea to me and users can be reminded of it with a message at the end of the run (Something like: "Once you are happy with your BOM, you can run 'kicost' with the '--price' option to actually get the pricing."

@leoheck
Copy link
Author

leoheck commented Jun 10, 2020

You got my point. Thanks.

This message at the end saying the following would be really good agree too.

Once you are happy with your BOM, you can run Kicost with the '--price' option to actually get the pricing.

For instance, yesterday I was working to debug some functionalities of this tool and using it for the first time. I was also testing the stable version 1.1.4 and the version from the master. Today, when I finally got the tools and my project working I can't even have a quotation since the Kitspace does not reply to the Kicost.

Now, I know this --no_price flag. New users don't tune the command line when they don't know how to use the tool yet.

@miili
Copy link

miili commented Aug 2, 2020

Is there an insight how many requests are available and in the pool?

@set-soft
Copy link
Collaborator

Is there an insight how many requests are available and in the pool?

This is a question for @kasbah and I have another:
As we are discussing it: Octopart API (what KitSpace uses) replies with 429 (Too many requests) when you reach the limit.
What @leoheck posted seems to be a 504 (Gateway timeout) error.
Does KitSpace also reply with 429 when Octopart says 429 to KitSpace?
I can add a case for 429 to KiCost.

About the --price: I don't agree, the KitSpace queries are really slow, the user should get bored and choose --no_price. Is in the --help and you can deselect all distributors in the GUI. The main point of KiCost is the price. If you get an empty spreadsheet you'll think the tool doesn't work. In fact I want to make KiCost fill the cells to avoid the impression that they are empty (until you force a recomputation).

And about the stack trace: Now KiCost shows a red error and no stack trace. So the main issue here (friendly message) is solved. If KitSpace can report 429 this will be much better.

@set-soft set-soft added the enhancement Improvements on features already existent. label May 24, 2021
@kasbah
Copy link
Contributor

kasbah commented May 24, 2021

The pool is currently 5000 requests per month.

We don't yet give a proper response when we hit the limit. We just error and then let it timeout. The most relevant code in our API is here. I've not gotten around to adding the the ability to give a proper response there.

@leoheck
Copy link
Author

leoheck commented May 24, 2021

About the --price: I don't agree,

Sure, @set-soft if the tool works every time the user will use it, I agree. But since the tool does not work anymore after a couple of tries, this can be an issue. This happened was for me when trying to use it for the first time. Since I was testing and experimenting to make it work, I had to run it too many times. And then I realized that right after being able to use it, I could not use it anymore since I could not make more requests to that server.

This may also be a problem if you are working in a place where you have many people using the tool and you just have a single external IP, as a normal company is.

The idea for an inverted flag is just to make sure you will be able to run when needed.

@leoheck
Copy link
Author

leoheck commented May 24, 2021

What @leoheck posted seems to be a 504 (Gateway timeout) error.
Does KitSpace also reply with 429 when Octopart says 429 to KitSpace?
I can add a case for 429 to KiCost.

Well, this can be right. This issue was created one year ago.

@kasbah
Copy link
Contributor

kasbah commented May 24, 2021

What do you mean by "this can be right" ?

@leoheck
Copy link
Author

leoheck commented May 24, 2021

This means that @set-soft might be right assuming that because I have no idea why it was not working for me after using for a couple of times that time.

@mdeweerd
Copy link
Contributor

About the --price: I don't agree, the KitSpace queries are really slow, the user should get bored and choose --no_price.

Actually, one thing about kicost is the price... Getting nices BOMs with the variants feature is a pretty strong feature as well.
I am often surprised about how lazy a user is to examine the manual and does not seek to optimize because "it works".
I am in favor of a --price option rather than a --no_price option.
This could be a question a the end of reading in the files for instance:

KiCost V...
All files were read succesfully.
10 out of 23 components are missing a manufacturer number:
- R1, 10k,  [...]
- C10, 10u, [...]
- ...

Continue with price calculation ? (the number of API calls is limited, please make fair use of it!) ?
You can add `--price` as an option or Type "PRICE" to compute it now (PRICE/<ENTER>):

@set-soft
Copy link
Collaborator

About the --price: I don't agree,

Sure, @set-soft if the tool works every time the user will use it, I agree. But since the tool does not work anymore after a couple of tries, this can be an issue.

I created the regression tests without this problem. And they are far more than a couple ;-)

Lamentably Octopart asks for a credit card to give a free key. I don't want to take the risk of being "accidentally" charged, so I didn't asked for a free key. But you can try it. They give 500 queries a month for free.

Another option to offload KitSpace could be the implementation of the APIs for the major distributors. Digi-key provides a free key with 1000 queries by day this is more than enough for regular use. The API is already implemented in Python https://github.com/peeter123/digikey-api I'm doing a lot of work on KiCost and I'm very delayed with the KiBot integration, so I can't say I'll add Digi-Key support.

We can try adding a warning, enabled by default and disabled using an environment variable (or a command line option for people too lazy to define environment variables). Hey @hildogjr ! What do you think about such a warning? Something like

KitSpace resources are limited, please include prices only after you finished fine tunning the BoM.
In the meantime use --no_price (command line) or deselect all distributors (GUI).

@set-soft
Copy link
Collaborator

The pool is currently 5000 requests per month.

Thanks for the info

We don't yet give a proper response when we hit the limit. We just error and then let it timeout. The most relevant code in our API is here. I've not gotten around to adding the the ability to give a proper response there.

I don't know enough Java Script to help with it. If you manage to reply 429 just tell me and I'll add a nice message to KiCost explianing the probem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements on features already existent.
Projects
None yet
Development

No branches or pull requests

6 participants