libcloud icon indicating copy to clipboard operation
libcloud copied to clipboard

Get GCE image price

Open Eis-D-Z opened this issue 3 years ago • 8 comments

Add new method to get gce image price

 Add tests

Description

Getting GCE image price right now with libcloud.pricing.get_pricing(driver_type='compute', driver_name='gce_images') is broken. I added a separate method to do that since gce images price dictionary veers off the pattern of the rest of the pricing data. I added some tests that use directly the pricing data and not the mock pricing data, on purpose, the main reason is to detect any changes in the format of the pricing data by Google.

Status

  • done, ready for review

Checklist (tick everything that applies)

  • [x] Code linting (required, can be done after the PR checks)
  • [x] Documentation
  • [x] Tests
  • [x] ICLA (required for bigger changes)

Eis-D-Z avatar May 25 '22 15:05 Eis-D-Z

Codecov Report

Merging #1699 (de44494) into trunk (027b668) will decrease coverage by 0.00%. The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##            trunk    #1699      +/-   ##
==========================================
- Coverage   83.29%   83.28%   -0.01%     
==========================================
  Files         400      400              
  Lines       87774    87862      +88     
  Branches    10690    10708      +18     
==========================================
+ Hits        73108    73180      +72     
- Misses      11486    11495       +9     
- Partials     3180     3187       +7     
Impacted Files Coverage Δ
libcloud/pricing.py 68.93% <68.62%> (-0.20%) :arrow_down:
libcloud/test/test_pricing.py 97.56% <100.00%> (+1.04%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 027b668...de44494. Read the comment docs.

codecov-commenter avatar May 25 '22 15:05 codecov-commenter

Short therm this change looks good to me, but long term we should figure out how we can integrate it into standard get_size_pricing() method.

Kami avatar Jun 05 '22 10:06 Kami

@Eis-D-Z Thanks for the contribution. Would it be possible to implement something like this https://github.com/apache/libcloud/pull/1699/files#r889676868?

Kami avatar Jun 05 '22 10:06 Kami

Hey Tomaz, Of course, sorry for the delay. I am on it.

Eis-D-Z avatar Jun 06 '22 21:06 Eis-D-Z

Hi Tomaz, I'm very sorry, I got some issues and only just now resolved them. I can continue to improve the PR to be inline with the overall philosophy. I do have some questions though:

  1. get_size_price has size in its name so it might be misleading to return image price, do you want to rename the method or are you cool with this.

  2. I will need to add two arguments, image_name and cores, and naming is my weak point. Are those names alright?

  3. I am preparing another PR with prices for EC2, because AWS have added to their official endpoint prices. (The same endpoint where we get the sizes) I will open it within the day on a separate PR, I believe you wouldn't want to add it in this PR.

Cheers Alex

Eis-D-Z avatar Jun 17 '22 09:06 Eis-D-Z

@Eis-D-Z

  1. In this case, to reduce confusion it would probably be better to introduce a new function, e.g. get_image_price or similar.

  2. If we go with 1), I assume those arguments will then be added to this new function? I guess it may still be somewhat confusing since "cores" implies size to some extent, but I know that some image licensing is based on number of cores, so it probably also fine / make sense to add it there.

Kami avatar Jun 28 '22 20:06 Kami

Ok I will go with 1. Message ID: @.***>

Eis-D-Z avatar Jul 04 '22 08:07 Eis-D-Z

@Eis-D-Z Changes look good to me, but unit tests appear to be failing. Can you please have a look when you get a chance? Thanks.

Kami avatar Jul 23 '22 17:07 Kami

@Eis-D-Z How is this PR looking? Would be great if we could get it wrapped up merged. Thanks.

Kami avatar Sep 05 '22 08:09 Kami

@Kami Excuse me for the delay.

Eis-D-Z avatar Sep 05 '22 17:09 Eis-D-Z