Skip to content
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

Reference directories when using config file #15

Closed
ghost opened this issue May 15, 2022 · 7 comments
Closed

Reference directories when using config file #15

ghost opened this issue May 15, 2022 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented May 15, 2022

It is told that if reference_directories list is empty, they become equal to test_directories list (which is strictly required in any variant).

But it is not told (at least it is not cleared out) that if using tool with -c flag, reference_directories list should be provided non-empty in config file and it will not become equal to (copied from) test_directories list.

And this 'cross-confusing rule' got confirmed when I've inspected the code here (copy) and here (no copy) that empty reference_directories is only allowed for full-optioned CLI run, but not with -c-run.

Can you state this restriction more clear in the docs or, probably better - update the -c mode to behave equal to full-optioned run?

@blingenf
Copy link
Owner

I believe the configuration file also requires noise_threshold, guarantee_threshold, and display_threshold to be explicitly specified which is not true for the CLI. I don't remember my original reasoning for that, but the configuration definitely should behave identically to the CLI method. I'll adjust how the defaults are handled.

@blingenf blingenf self-assigned this May 15, 2022
@blingenf blingenf added the bug Something isn't working label May 15, 2022
@ghost
Copy link
Author

ghost commented May 16, 2022

Thank you for quick response!

Maybe moving code before reading config file to place right after could help, but I cannot be sure as I did not dig into the sources much yet.

Just discovered that for API CodeDetector object with config=dict option the reference_directories are copied from test_directories, which is a good point in this case.

@blingenf
Copy link
Owner

I decided it was best to deal with the root cause of this issue, which is allowing both a config file and specific parameters to be passed as arguments to the CopyDetector initializer. For future versions I'm planning on separating these two initialization methods. To initialize with a config file you would need CopyDetector.from_config(config)

The PR is here: #16. If this change would be particularly disruptive for your project feel free to comment on the PR.

@ghost
Copy link
Author

ghost commented May 22, 2022

It's not a big deal, I am ready to update my project once the new release is coming to the PyPi, since I am using this tool as the pip requirement.

@ghost
Copy link
Author

ghost commented May 22, 2022

Is it correct that from now API allows only 2 options: a) full config parameters set up and b) passing config file instead? So I need to save current config dict to file first and then pass the file path to process?
Asking because the PR description says it's a config file, but from the code it's still a config dict object argument.

@blingenf
Copy link
Owner

Is it correct that from now API allows only 2 options: a) full config parameters set up and b) passing config file instead? So I need to save current config dict to file first and then pass the file path to process? Asking because the PR description says it's a config file, but from the code it's still a config dict object argument.

Sorry, the PR description could have been more clear. It's still a dict object, so you won't have to save it first.

@blingenf
Copy link
Owner

The fix is in version 0.4.1 and is now on pypi. Your existing code should still work but when you switch to the from_config function make sure to require copydetect>=0.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant