Skip to main content

Utilities

The Graphora client library provides utility functions for common tasks. This page provides a reference for all the utility functions in the library.

YAML Utilities

load_yaml

Load YAML from a file.

Example

save_yaml

Save data as YAML to a file.

Example

Environment Utilities

get_api_url

Get the API URL for the specified environment.

Example

Best Practices

Working with YAML

When working with YAML files, consider these best practices:
  1. Handle Exceptions: YAML parsing can fail if the file is malformed
  2. Validate Paths: Ensure file paths exist before trying to load or save
  3. Use Path Objects: Path objects handle cross-platform path issues

Working with Environment Variables

When working with environment variables, consider these best practices:
  1. Provide Defaults: Always provide sensible defaults
  2. Use Environment Files: Consider using .env files for local development
  3. Environment-Specific Configuration: Use different configurations for different environments

Complete Example

Here’s a complete example of using the utility functions:

Next Steps