Skip to content

Package import fails if fastfuels key not set as an envrionment variable #112

@wxcutch

Description

@wxcutch

I just installed the sdk in a fresh conda environment. When I run from fastfuels_sdk import api I get the following error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[1], line 1
----> 1 from fastfuels_sdk import api

File ~/miniconda3/envs/fastfuels/lib/python3.13/site-packages/fastfuels_sdk/__init__.py:1
----> 1 from fastfuels_sdk.domains import Domain, list_domains
      2 from fastfuels_sdk.inventories import Inventories, TreeInventory
      3 from fastfuels_sdk.features import Features, RoadFeature, WaterFeature

File ~/miniconda3/envs/fastfuels/lib/python3.13/site-packages/fastfuels_sdk/domains.py:21
     11 from fastfuels_sdk.client_library.api import DomainsApi
     12 from fastfuels_sdk.client_library.models import (
     13     Domain as DomainModel,
     14     CreateDomainRequest,
   (...)     18     UpdateDomainRequest,
     19 )
---> 21 _DOMAIN_API = DomainsApi(get_client())
     24 class Domain(DomainModel):
     25     """Domain resource for the FastFuels API.
     26 
     27     Represents a spatial container that defines geographic boundaries for fire behavior modeling and analysis.
   (...)     78     list_domains : List available domains
     79     """

File ~/miniconda3/envs/fastfuels/lib/python3.13/site-packages/fastfuels_sdk/api.py:32, in get_client()
     30 api_key = os.getenv("FASTFUELS_API_KEY")
     31 if not api_key:
---> 32     raise RuntimeError(
     33         "FASTFUELS_API_KEY environment variable not set. "
     34         "Please set this variable with your API key."
     35     )
     36 config = {
     37     "header_name": "api-key",
     38     "header_value": api_key,
     39 }
     41 _client = ApiClient(**config)

RuntimeError: FASTFUELS_API_KEY environment variable not set. Please set this variable with your API key.

In case someone else is having the same issue and also doesn't want to globally set the environment variable, I put this in the code block before the import to fix it:

import os
os.environ['FASTFUELS_API_KEY'] = 'your-key-here'

Metadata

Metadata

Assignees

Labels

🔥 hot fixThere's a bug, fix it immediately

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions