JunaidAhamed-7777 opened a new issue, #2225:
URL: https://github.com/apache/libcloud/issues/2225

   ## Summary
   
   The pricing guide tells users to put custom pricing in 
`~/.libcloud.pricing.json`, but Libcloud reads `~/.libcloud/pricing.json`. 
Following the documented setup leaves the custom data unused.
   
   At current trunk `8a0ef6260680625d54fce5093d2315e0926a7dc9`, the incorrect 
path appears twice under **Using a custom pricing file** and once under 
**Updating pricing** in 
[docs/compute/pricing.rst](https://github.com/apache/libcloud/blob/8a0ef6260680625d54fce5093d2315e0926a7dc9/docs/compute/pricing.rst#L91-L119).
   
   ## Detailed Information
   
   Reproduced with Python 3.12 on Linux using unchanged Libcloud `4.0.0.dev0`. 
This uses temporary directories and fresh subprocesses, so an existing 
home-directory file or in-memory pricing cache does not affect the result. No 
cloud service or pricing-data download is involved.
   
   ```python
   import json
   import os
   import subprocess
   import sys
   import tempfile
   from pathlib import Path
   
   probe = '''
   from libcloud import pricing
   path = pricing.get_pricing_file_path()
   print("selected", "custom" if path == pricing.CUSTOM_PRICING_FILE_PATH else 
"bundled")
   try:
       print("price", pricing.get_size_price("compute", "local_probe", "small"))
   except KeyError:
       print("custom driver unavailable")
   '''
   
   with tempfile.TemporaryDirectory() as tmp:
       home = Path(tmp)
       content = json.dumps({"compute": {"local_probe": {"small": 0.125}}, 
"storage": {}})
       (home / ".libcloud.pricing.json").write_text(content)
       env = dict(os.environ, HOME=tmp)
       subprocess.run([sys.executable, "-c", probe], env=env, check=True)
       # selected bundled
       # custom driver unavailable
   
       (home / ".libcloud").mkdir()
       (home / ".libcloud" / "pricing.json").write_text(content)
       subprocess.run([sys.executable, "-c", probe], env=env, check=True)
       # selected custom
       # price 0.125
   ```
   
   The expected documentation path is `~/.libcloud/pricing.json`, matching 
`CUSTOM_PRICING_FILE_PATH`, `get_pricing_file_path()` and the existing upgrade 
notes. With the documented dot-separated path, the loader silently falls back 
to bundled data; for this synthetic custom-only driver the lookup then raises 
`KeyError`.
   
   The **Updating pricing** paragraph also says the default download source is 
the git repository, while the function currently defaults to 
`DEFAULT_FILE_URL_S3_BUCKET`; the preceding section already describes that S3 
service. It would be useful to bring that paragraph into line with the current 
defaults at the same time.
   
   This is a documentation report, not a change to actual prices or a claim 
about provider billing. No full test suite or live download was run.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to