fast-aircraft-design / FAST-OAD

FAST-OAD: An open source framework for rapid Overall Aircraft Design
GNU General Public License v3.0
47 stars 25 forks source link

Defining file name in .yaml file for module option using your proper resource folder #327

Open areysset opened 3 years ago

areysset commented 3 years ago

I'm currently using my proper folder for the aerodynamics airfoils profile file (in aerodynamics). The .toml (and now .yaml) was giving as an option the file name my_naca.af and aerodynamics was previously (v0.5.4b version of FAST-OAD) looking for the file in my dedicated path using copy_ressource function (see openvsp.txt).

The problem is now FASTOADProblemConfigurator._parse_problem_table() includes auto-completion for passed option whose name finish by file (ex: wing_airfoil_file): name.endswith("file") = True Which lead to have as an option my_oad_test_function_path\my_naca.af: options[name] = pth.join(conf_dirname, option_value)

And that leads to an error for me since the file is obviously not located here. I think it should be mentioned for users at least (or corrected if it was not the way pretending to be used). My way around will be to rename the options in my dedicated function to avoid that issue (because I want beginner users to use airfoil names that can be listed and not specify complete path).

oad_process_be76.txt openvsp.txt

christophe-david commented 3 years ago

Agreed, this part should be better documented.

We have to use this trick for many other options to work: it is often natural to allow that the configuration file contains relative path for some file-related options, and we cannot handle that at module level, where the path of the configuration file is not available.

As you have seen, modifying the option name is a solution. But if you expect your user to be able to provide its own file also, then he will have to provide an absolute path, because you avoid the mechanism that resolves relative paths from the folder of configuration file.

A second solution is what we use in the performance module, where we need to provide the possibility to choose a mission file that can be bundled, or custom. When choosing a bundled file, user has to provide the name, preceded by ::. Currently, this trick is managed in the mission module, that trims whatever is found before ::, but we should probably provide this mechanism in a general way.