Skip to content

Conversation

@InfinityByTen
Copy link
Member

Added to template adding describe to optional resources.
Prepended a newline for readability.

Signed-off-by: Aseem Dua <[email protected]>
Signed-off-by: Aseem Dua <[email protected]>
@VeaaC
Copy link
Collaborator

VeaaC commented Jun 2, 2020

Can you add some unit tests as well (GeneratedArchiveTests)?:

  • test that a failed sub-archive can be described
  • test that a failed optional sub-archive can be described

Test that if sub-archive is unintialized, it's in the describe.
Test if schema mismatches in optional sub-archive, you get a fatal error
and it is in the describe.
The mandatory sub-archive case is present in an existing test.

Signed-off-by: Aseem Dua <[email protected]>
}

TEMPLATE_TEST_CASE_METHOD( Fixture,
"Uninitialized sub-archive is descried",
Copy link
Collaborator

Choose a reason for hiding this comment

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

desried -> described

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah sure, will fix.

std::string description;
if ( initialized )
{
description = std::is_base_of< Archive, ResourceType >::value
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about:

  • describing resourcing is sub-archives that failed to initialize? How does that look like now?
  • describing resources in sub-archives that successfully loaded, how does that look like now?

I guess it might need to look like a tree-structure, e.g.:

resource1 : ...
archive_resource1: ...
    sub_resource1: ...
    sub_resource2: ...

Copy link
Member Author

Choose a reason for hiding this comment

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

  • Uninitialized is reported as an error only in mandatory case. But then it doesn't stop us from describing the Archive child resources instead of keeping it "N/A". Will adapt it.

  • If everything is initialized, then then describe works but there is no indentation and everything is flattened out (it's flatdata after all). But I'll try to see if there's a nice way to get indentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would you suggest a tree structure with complete descriptions like so? :
flatdata_tree_describe

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks a bit hacky... how about having a single combined list, but full resource names:

outermost
outer
outer.outer1
outer.outer2
outer.inner
outer.inner.inner

That could require passing down the path-prefix, and being able to disable headers/footers during recursive calls

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, first versions are mostly hacky. Anyhow, I've reworked it a bit based on your inputs. I would like to retain the tree structure and somehow include which ones are archives and which are plain structs. Here's how the latest version looks:
describe_reworked

Let me know what you think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good!

Signed-off-by: Aseem Dua <[email protected]>
Whether a resource is initialized or not, it will always display
some details. For optional entities, a dummy is created to extract
the name of the type to give maximum information to the user.

Nested levels do not print headers.

Signed-off-by: Aseem Dua <[email protected]>
@InfinityByTen
Copy link
Member Author

I seem to often run into this issue of tests failing on CI. This time it happened because I just had forgotten where to run the tests from. Should we have a separate task to put into a README how to run tests locally?

Signed-off-by: Aseem Dua <[email protected]>
@VeaaC
Copy link
Collaborator

VeaaC commented Jul 10, 2020

I seem to often run into this issue of tests failing on CI. This time it happened because I just had forgotten where to run the tests from. Should we have a separate task to put into a README how to run tests locally?

That makes sense: Some How to contribute section with advice how to test the individual components:

  • How to use local generator via export FLATDATA_GENERATOR_PATH=${PWD}/../flatdata-generator
  • python -m nose for generator tests
  • how to manually run generator for a test to get a new reference, e.g. ./generator.py -s ../test_cases/archives/multivector.flatdata -g rust -O tests/generators/rust_expectations/archives/multivector.rs.1
  • how to update the checked in generated rust test code, e.g.: ../flatdata-generator/generator.py -s lib/src/test/test.flatdata -g rust -O lib/src/test/test_generated.rs && sed -i 's/flatdata::/crate::/g' ../flatdata-rs/lib/src/test/test_generated.rs
  • etc

Do you want to create a new issue for that? And would you like to fill that yourself, or have it filled by regular contributors?

Signed-off-by: Aseem Dua <[email protected]>
@InfinityByTen
Copy link
Member Author

Do you want to create a new issue for that? And would you like to fill that yourself, or have it filled by regular contributors?

I can create an issue as a starting point, definitely. But I guess I don't have enough insight as to what all it could include. Like I literally had no idea about half the things you mentioned.

}
else
{
auto dummy = new ResourceType( );
Copy link
Collaborator

Choose a reason for hiding this comment

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

You are leaking memory here, just create the object on the stack?

const bool is_archive = std::is_base_of< Archive, ResourceType >::value;

const ResourceType ref = initialized ? *resource // valid ref
: *( new ResourceType( ) ); // ref to dummy, not used
Copy link
Collaborator

Choose a reason for hiding this comment

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

You are leaking memory here, just create the object on the stack?

size_t size_in_bytes( ) const;
size_t size( ) const;
std::string describe( ) const;
std::string describe( size_t unused = 0u ) const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

give unused arguments their normal name, so users know what they are


std::string
describe( ) const
describe( size_t unused = 0 ) const
Copy link
Collaborator

Choose a reason for hiding this comment

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

size_t /name_of_variable/ ?

Resource Optional Too Large Loaded Details
================================================================================
outer NO NO YES Structure of size 1
archive_resource YES NO NO FATAL: Resource storage not initialized. Please check archive path.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the FATAL should be removed, since it is not fatal for optional subarchives

Same if true for check archive path.

Can you rephrase it into a neutral message? Or have a different message for root and nested?

@VeaaC VeaaC merged commit 8839fb3 into heremaps:master Aug 7, 2020
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.

2 participants