-
-
Notifications
You must be signed in to change notification settings - Fork 329
Implement print_config_info application command #2382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
application/F3DConfigFileTools.cxx
Outdated
// Clear config file paths to avoid reading them if dryRun is set | ||
if (dryRun) | ||
{ | ||
actualConfigFilePaths.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insteaed you may want to just return ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I will do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
Please add a test though, you can look at
application/testing/CMakeLists.txt:1101
TestCommandScriptPrintScene
and copy the logic.
Nice! thanks @NaniNoni As it is, from a user point of view, this could answer "where are the current config files?" but not "where should I create my config file?" as only the existing files are listed? How about removing the f3d/application/F3DConfigFileTools.cxx Line 66 in 3bec77e
ReadConfigFiles where both existing and non-existing files could be logged accordingly?
|
Thank you, will do |
I fixed/implemented the requested changes. However, in the loop over canonical paths, I ended up using // Recover an absolute canonical path to config file
try
{
configPath = fs::canonical(fs::path(configPath)).string();
}
catch (const fs::filesystem_error&)
{
// This (file not found) error is expected in dry run mode
if (dryRun)
{
f3d::log::print(logLevel, "Found available config location ", configPath.string());
}
else
{
f3d::log::debug(
"Configuration file does not exist: ", configPath.string(), " , ignoring it");
}
continue;
} |
application/F3DConfigFileTools.cxx
Outdated
} | ||
configPath = dir / configName; | ||
paths.emplace_back(configPath); | ||
f3d::log::debug("Found potential config file: ", configPath.string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you changed the logic a bit so that GetConfigPath does not check existence.
TBH I dont think this is needed. You can control the logLevel instead so it doesnt debug only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not convinced by the new impl :/
Would it be better to improve the separation of concerns between The idea would be:
|
I like this idea a lot |
I implemented the requested changes. The only downside I'm aware of is that the std::vector<std::filesystem::path> availableConfigPaths =
F3DConfigFileTools::GetConfigPaths("config"); |
You'd have to track down where the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this implementation. It looks to me this will not output anything about config files now ? We want the same or at least a similar output when --verbose
is used.
application/F3DConfigFileTools.cxx
Outdated
configPath = fs::canonical(fs::path(configPath)).string(); | ||
} | ||
catch (const fs::filesystem_error&) | ||
if (!fs::exists(configPath)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need a try catch around this call
Yes, you're right. That's another problem. Previously to these changes, the Now, the existence check in |
Yes I agree. @mwestphal how would you like this to work? |
Alright, actually your implementation is not far off! How about adding another method:
that prints output using log::info like this by checking the file/dir existence:
And use it in |
Hi @NaniNoni , how is it going ? Do you need any help ? |
1 similar comment
Hi @NaniNoni , how is it going ? Do you need any help ? |
Hi, sorry for the delay. I've been away and then unexpectedly very busy, but I've implemented the changes and it should hopefully be closer to the desired implementation. However, the quoted comment below is still unresolved. How would you like this to work?
|
/** | ||
* Recover a OS-specific vector of potential config file directories | ||
*/ | ||
std::vector<std::filesystem::path> GetConfigPaths(const std::string& configSearch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::vector<std::filesystem::path> GetConfigPaths(const std::string& configSearch); | |
std::vector<fs::path> GetConfigPaths(const std::string& configSearch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good. I found a small issue to fix. Next time you push the CI will run.
void F3DConfigFileTools::PrintConfigInfo(const std::vector<fs::path>& configPaths) | ||
{ | ||
for (const fs::path& path : F3DConfigFileTools::GetConfigPaths("config")) | ||
{ | ||
if (fs::exists(path)) | ||
{ | ||
f3d::log::info("Config file found: ", path); | ||
} | ||
else | ||
{ | ||
f3d::log::info("Candidate config file not found: ", path); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say we can get rid of this method and log specifically in ReadConfigFiles
and the print_config_info
command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean doing something like
for (const fs::path& path : F3DConfigFileTools::GetConfigPaths("config"))
{
f3d::log::info("- ", path, fs::exists(path) ? "(found)" : "(not found)");
}
in the command and logging in the existing if (!fs::exists(configPath))
branches in ReadConfigFiles()
(and it may not need to be info
level there?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think that works ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha right, sure, that works too :)
@NaniNoni you need to rebase on latest master |
Hi @NaniNoni , need any help moving forward ? |
1 similar comment
Hi @NaniNoni , need any help moving forward ? |
Describe your changes
I implemented the
print_config_info
command to allow for easily checking which config files are loaded. This is especially useful when f3d is ran not from the command line.Issue ticket number and link if any
#2349
Checklist for finalizing the PR
.github/workflows/versions.json
, I have updatedtimestamp
Continuous integration
Please check the checkbox of the CI you want to run, then push again on your branch.