Skip to content

Conversation

@soswow
Copy link
Contributor

@soswow soswow commented Sep 10, 2025

No description provided.

Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
Signed-off-by: Aleksandr Motsjonov <[email protected]>
}
else
{
check_and_add_file( path, batches[0] );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was actually a bug cought by the unit test. Horray for unit tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what makes you think this was a bug? the code does exactly what was intended, see main.cpp#40

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. That is rather specific expectation. If it was private API and used internally, I'd see no problem with that. But expecting caller to know that expectation seems specific. Happy to revert and modify the test. You can imagine test is failing when std::vector<std::vector<std::string>> batches; is empty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the split between main/util is not optimal here, perhaps the outer loop (main.cpp#44) should be also moved inside collect_image_files.
My point is, creating a new batch for each individual file was not the intended use.
The logic was: rawtoaces file1 file2 dir1 dir2 file3 should create 3 batches: [file1, file2, file3], [dir1/*], [dir2/*]

Copy link
Contributor Author

@soswow soswow Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. I didn't know it was intended behaviour. Now I know. I've refactored basd on your suggestion. Now there is no need for boolean return, so batches is the return now. I've added a test that checks that exact behaviour.

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.29%. Comparing base (bced9df) to head (2642889).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #192      +/-   ##
==========================================
+ Coverage   71.40%   73.29%   +1.89%     
==========================================
  Files          10       10              
  Lines        2196     2198       +2     
  Branches      236      237       +1     
==========================================
+ Hits         1568     1611      +43     
+ Misses        628      587      -41     
Files with missing lines Coverage Δ
include/rawtoaces/image_converter.h 100.00% <ø> (ø)
src/rawtoaces_util/image_converter.cpp 54.87% <100.00%> (+4.26%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bced9df...2642889. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

namespace util
{

bool collect_image_files(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is public API, so I guess I can drop it and use one from /include if you want

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes please, no need to duplicate things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: Aleksandr Motsjonov <[email protected]>
* false if the file should be ignored
*/
bool check_and_add_file(
void check_and_add_file(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean is not used in any way

}
else
{
check_and_add_file( path, batches[0] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what makes you think this was a bug? the code does exactly what was intended, see main.cpp#40

namespace util
{

bool collect_image_files(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes please, no need to duplicate things.

catch ( const std::exception &e )
{
std::cerr << "Exception caught in main: " << e.what() << std::endl;
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not that this is important, but should this be return unit_test_failures + 1;, as returning 1 discards all other failures we've found so far

OIIO::ImageSpec spec;

// Add integer attribute (this should be ignored by fix_metadata)
spec["Make"] = 42; // Integer, not string or float
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we think that camera make can be float, but not int

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know 🤷 That's the main problem not doing TDD and writing tests (contract) after impl. was written. (especially by a different brain)

if ( type.basetype == OIIO::TypeDesc::STRING )
    spec[dst_name] = src_attribute->get_string();
else if ( type.basetype == OIIO::TypeDesc::FLOAT )
    spec[dst_name] = src_attribute->get_float();

You tell me why we want attribute to be allows in as a float and a string, but not int. Happy to fix prod. code if there is a way to remove it.
This test just tests functionality that is already there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see what happened. The fix_metadata() originally had more attributes than just make and model. Could you delete that "else if float" branch for now, we'll add the allowed types to the mapping dictionary later when needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. makes sense. I am very big fan of removing code =)

}

/// Tests database_paths with Windows-style path separator
void test_database_paths_windows_separator()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we test the windows separator, but no the unix one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't need it. it's kinda stupid. If someone changes window separator, test_database_paths_default would brake.

Signed-off-by: Aleksandr Motsjonov <[email protected]>
} ),
batches.end() );

return batches;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see how it is used later on in main

for ( auto const &batch: batches )
    {
        for ( auto const &input_filename: batch )
        {

so, this ^ would deal with empty batches no problem, but from API perspective it doesn't make sense to have empty batch in return. So removing empty won't brake consumer, but make result cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does make sense though. It really depends on how the client needs the pipeline organised.

Example: rawtoaces dir1 dir2 dir3, if it returns 2 batches, there is no way to know which one was empty on the client side if it is removed in lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I've reverted it back. Empty batches are back.

@antond-weta antond-weta merged commit f6ad40c into AcademySoftwareFoundation:main Sep 11, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants