RWTH-EBC / FiLiP

FIWARE Library for Python (FiLiP) to work with FIWARE API
BSD 3-Clause "New" or "Revised" License
23 stars 13 forks source link

237 update and refactor examples #278

Closed WaltherTrgovac closed 2 months ago

WaltherTrgovac commented 4 months ago

Closes #237.

Current state of examples\ngsiv2 that have been worked on:

Before: Before

After: after2

Examples:

TODO: The directories of the examples and the numeration of the examples has to be adjusted. For example, we have two examples with the number 11 in the ngsiv2 directory, and the examples in the basics directory also need adjustment. README.md then also needs to be adjusted accordingly.

Maghnie commented 2 months ago

@WaltherTrgovac could you please update the examples readme file? Specifically:

Maghnie commented 2 months ago

Now there is some problem with the reading of .env.filip . It seems like the variables will only be correctly loaded when the .env.filip is put under the path of the examples, i.e. examples/ngsi_v2/ or examples/basics/ @WaltherTrgovac could you have a look on that? If necessary you can modify the filip/config.py, where the variables are loaded

Wasn't it always like that? I think in the config of filip it says that the env file should be in the working directory, so it's up to the user to take care of that.

WaltherTrgovac commented 2 months ago

Now there is some problem with the reading of .env.filip . It seems like the variables will only be correctly loaded when the .env.filip is put under the path of the examples, i.e. examples/ngsi_v2/ or examples/basics/ @WaltherTrgovac could you have a look on that? If necessary you can modify the filip/config.py, where the variables are loaded

If I am understanding this correctly, the method SettingsConfigDict in the class Settings is taking the path of the .env.filip file. It was set so that it is found only when the files to execute are in the same directory as the .env.filip. I have now adjusted that path so that the file can be located anywhere in the repository. I use the glob python package for that. First I locate the path of the repository with GitPython package and use that as the root directory. Then I look through the whole repository for the .env.filip file. The problem is that the .env.filip is a hidden file and glob package supports searching for hidden files only from the Python version 3.11... 😞. If somebody knows a solution for the earlier versions of Python that would be great. And another thing, I have no idea how to test this implementation, I have just tested it manually...

djs0109 commented 2 months ago

If somebody knows a solution for the earlier versions of Python that would be great.

Never mind, I have changed it now

Maghnie commented 2 months ago

If somebody knows a solution for the earlier versions of Python that would be great.

Never mind, I have changed it now

Then to avoid confusion between multiple env files, we should probably remove the copy under basics. Or do you see another use for it?

djs0109 commented 2 months ago

Nice hint. No we don't need it any longer

djs0109 commented 2 months ago

Now only e6 cannot work, because the code regarding data model creation is not yet migrated to pydantic V2