thiarthur / eolic

Event Oriented Link and Integration Controller
MIT License
6 stars 1 forks source link

Implement JSON File Reading Utility #10

Open angeloalvarez opened 3 months ago

angeloalvarez commented 3 months ago

Is your feature request related to a problem? Please describe.

The primary use case for this utility is to read configuration files that can be integrated into the initialization process of an existing class. This will enhance the flexibility of the class by allowing configurations to be easily loaded and modified via external JSON files.

Describe the solution you'd like

I would like to implement a utility function for reading JSON files to enhance the way our project handles external configurations and data. The proposed solution involves creating a dedicated package within our project structure to manage file reading operations. Specifically, the read_json_file function will be designed to:

Describe alternatives you've considered

One alternative would be to continue hardcoding configurations directly within the class, but this would reduce flexibility and make it more difficult to update settings without modifying the code. Another option could involve using a different file format (e.g., YAML), with the potential for future support for YAML to allow even greater flexibility.

thiarthur commented 3 months ago

That's a great suggestion! This solution will also allow Eolic to be configured by config maps on K8s clusters.

Since we are already using the pydantic models to handle serializable schemas, we could use BaseSettings or the regular BaseModel to handle json, yaml, toml and also some future configuration by environment variables

angeloalvarez commented 1 month ago

Thank you for your insightful suggestion!

I’ve made the necessary changes to the code to implement this solution, which will indeed allow Eolic to be configured using config maps on K8s clusters. By leveraging Pydantic's BaseSettings, we can now efficiently handle JSON, YAML, TOML configurations, and future environment variable setups.

I hope this approach works well for you! If you have any thoughts or suggestions, I’d love to hear them!

feat/config-file