Skip to content

Commit

Permalink
Merge pull request #52 from inverted-ai/document-env-var
Browse files Browse the repository at this point in the history
Document env var
  • Loading branch information
Ruishenl committed Oct 21, 2022
2 parents 77a59d1 + 2156408 commit 3d8fc93
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/source/pythonapi/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sdk-initialize
sdk-location-info
sdk-simulation
sdk-common
sdk-env-var
```


11 changes: 11 additions & 0 deletions docs/source/pythonapi/sdk-env-var.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ENV_VAR



| name | default | options | description |
|:-----------:|:-----------:|:-----------:|:-----------:|
| IAI_LOG_LEVEL | `WARNING` | [`DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`]| Supported python logger levels|
| IAI_LOG_CONSOLE | `true` | [`y`, `yes`, `t`, `true`, `on`, `1`, `n`, `no`, `f`, `false`, `off`, `0`]| Whether to log to the console|
| IAI_LOG_FILE | `false` | [`y`, `yes`, `t`, `true`, `on`, `1`, `n`, `no`, `f`, `false`, `off`, `0`] | Whether to log to the file `iai.log`|
| IAI_API_KEY | `""` | NA | API Key needed to call the InvertedAI API|
| IAI_MOCK_API | `false | [`y`, `yes`, `t`, `true`, `on`, `1`, `n`, `no`, `f`, `false`, `off`, `0`] | If true it will call the Mock API instead|
5 changes: 3 additions & 2 deletions docs/source/userguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ Other than for the random seed, there is currently no mechanism to influence the
by directing them to certain exits or setting their speed, but such mechanisms will be included in future releases.

## Validation and debugging
To facilitate development of integration without incurring the costs of API calls, we provide a mock API version that
To facilitate development of integration without incurring the costs of API calls, we provide a way to mock API calls that
returns locally computed simple responses in the correct format. This mock API also performs validation of message
formats, including checking lengths of lists and bounds for numeric values, and those checks can also be optionally
performed on the client side before paid API calls. All those features are only available in the Python library and not
in the REST API.
in the REST API.
To enable the mock API, just set the environment variable `IAI_MOCK_API` to true according to {ref}`ENV_VAR`
For further debugging and visualization, both INITIALIZE and DRIVE optionally return a rendered birdview image showing
the simulation state after the call to them. This significantly increases the payload size and latency, so it should not
be done in real integrations.
6 changes: 3 additions & 3 deletions invertedai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from invertedai.cosimulation import BasicCosimulation
from invertedai.utils import Jupyter_Render, IAILogger, Session

dev = os.environ.get("IAI_DEV", False)
dev = strtobool(os.environ.get("IAI_DEV", "false"))
if dev:
dev_url = os.environ.get("IAI_DEV_URL", "http://localhost:8000")
log_level = os.environ.get("IAI_LOG_LEVEL", "WARNING")
log_console = os.environ.get("IAI_LOG_CONSOLE", 1)
log_file = os.environ.get("IAI_LOG_FILE", 0)
log_console = strtobool(os.environ.get("IAI_LOG_CONSOLE", "true"))
log_file = strtobool(os.environ.get("IAI_LOG_FILE", "false"))
api_key = os.environ.get("IAI_API_KEY", "")

logger = IAILogger(level=log_level, consoel=bool(log_console), log_file=bool(log_file))
Expand Down

0 comments on commit 3d8fc93

Please sign in to comment.