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

zeroeq::Server/Client based morphology loader #172

Merged
merged 11 commits into from
Aug 24, 2017
Merged

Conversation

eile
Copy link
Contributor

@eile eile commented Aug 4, 2017

No description provided.

@eile eile force-pushed the zeromorph branch 5 times, most recently from 7effdd2 to 00cb7b3 Compare August 4, 2017 07:51
@eile eile requested review from hernando, tribal-tec and rdumusc and removed request for hernando August 4, 2017 07:51
@eile
Copy link
Contributor Author

eile commented Aug 4, 2017

Retest this please.

@eile eile force-pushed the zeromorph branch 3 times, most recently from 12d03eb to e9e2cb6 Compare August 7, 2017 09:11
@eile
Copy link
Contributor Author

eile commented Aug 7, 2017

ping?

)
set(BRAIN_INCLUDE_NAME brain)
set(BRAIN_NAMESPACE brain)

if(TARGET MVDTool)
list(APPEND BRAIN_LINK_LIBRARIES PRIVATE MVDTool)
list(APPEND BRAIN_LINK_LIBRARIES MVDTool)
Copy link

Choose a reason for hiding this comment

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

Now I don't know if you're trying to make it PUBLIC or relying on the context to keep it PRIVATE. I would recommend leaving the keyword for readability.

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

{
namespace plugin
{
class MorphologyZeroEQ : public MorphologyPlugin, public servus::Serializable
Copy link

Choose a reason for hiding this comment

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

I'm confused at what this class represents. Why would anyone want to serialize a plugin? Especially when the base class is boost::noncopyable? It needs at the very least some documentation, possibly refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me see what I can do. It's both a serializable morphology (for brain & ZeroEQ) and the ZeroEQ plugin.

@@ -76,47 +47,20 @@ Morphology::Impl::Impl(const brion::Morphology& morphology)
somaSection = ids[0];
}

bool Morphology::Impl::_fromBinary(const void* data, const size_t size)
Morphology::Impl::Impl(const brion::Morphology& morphology)
: brion::plugin::MorphologyZeroEQ(morphology)
Copy link

Choose a reason for hiding this comment

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

Seriously, we have a brain::Morphology::Impl::Impl() which take a brion::Morphology& (which is itself a wrapper around a brion::MorphologyPlugin) and yet manges to derive from brion::plugin::MorphologyZeroEQ (a brion::MorphologyPlugin subclass) itself? I think that fuels my confusion below...

Copy link
Contributor Author

@eile eile Aug 8, 2017

Choose a reason for hiding this comment

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

^ see above. Likely I'll move the serializable morphology to a helper class.

Copy link
Contributor

Choose a reason for hiding this comment

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

This inheritance doesn't neither look right to me at all.
First of all, ZeroEQ is an optional dependency. Given that, making a core class of Brain depend on something that has the ZeroEQ suffix doesn't only smell fishy, is already rotten. Maybe it's just the naming because I haven't reached the class declaration yet, but it could also be that inheritance is used where it should be aggregation.

BOOST_AUTO_TEST_CASE(load_morphologies)
{
const brain::Circuit circuit(
(brion::URI("/home/eilemann/stable/Brion/BlueConfig")));
Copy link

Choose a reason for hiding this comment

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

home folder path? What happens if someone runs ninja Brion-perftests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accidental testing artefact. Fixed.

const brain::Circuit circuit(
(brion::URI("/home/eilemann/stable/Brion/BlueConfig")));
auto gids = circuit.getGIDs();
if (gids.size() > 50000)
Copy link

Choose a reason for hiding this comment

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

make this a function, something like:
resizeIfBiggerThan(gids, 50000);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

o_O

@@ -24,6 +24,13 @@ if(TARGET BBPTestData)
list(APPEND SPIKECONVERTER_LINK_LIBRARIES BBPTestData)
endif()

if(TARGET ZeroEQ)
set(MORPHOLOGYSERVER_HEADERS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove if empty.

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

@@ -24,6 +24,13 @@ if(TARGET BBPTestData)
list(APPEND SPIKECONVERTER_LINK_LIBRARIES BBPTestData)
endif()

if(TARGET ZeroEQ)
Copy link
Contributor

Choose a reason for hiding this comment

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

Keyv is also optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

common_find_package(Keyv REQUIRED) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Where did I looked at then...? I checked it before commenting.

if (value.ptr && value.size)
{
std::cout << 'c' << std::flush;
return zeroeq::ReplyData(brion::ZEROEQ_GET_MORPHOLOGY, value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's a bit late to add this comment here, but to me it seems wrong to require the request ID in the return value of this function. If the handler doesn't take any parameters to distinguish the request ID, it means that you can't bind the same function to multiple handlers, which in turns implies that the request ID is implicit. What's the reason for not returning a Serializable and let ZeroEQ figure out the right request ID to use (you could always return an empty answer returning by unique_ptr.

What does it happen is the user changes the request ID to something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It returns the reply ID, not the request ID (which in this use case is identical to the request ID). A handler may return different reply IDs to the same request, e.g., for error codes or different return value types.

Copy link
Contributor

Choose a reason for hiding this comment

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

That was not obvious by the code because in case of errors you're returning and empty reply.

<< " zeroeq://" << address << "/path/to/morphology" << std::endl
<< std::endl
<< " [c]ache read, [d]isk read with cache update, disk read "
"with cache [e]rror, [D]isk read uncached, morphology [l]oad error: "
Copy link
Contributor

Choose a reason for hiding this comment

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

I like u better that D for disk read uncached. So can rewrite it as [u]ncached disk read

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

#include <brion/morphology.h>
#include <brion/plugin/morphologyZeroEQ.h>
#include <keyv/Map.h>
#include <lunchbox/daemon.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not used

brion::Morphology& raw = loading.find(hash)->second;
neuron::MorphologyPtr morphology(
transform ? new neuron::Morphology(raw, transforms[i])
: new neuron::Morphology(raw));
Copy link
Contributor

Choose a reason for hiding this comment

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

You're not updating cached anymore, well, yes, with a nullptr above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. Fixed.

@@ -76,47 +47,20 @@ Morphology::Impl::Impl(const brion::Morphology& morphology)
somaSection = ids[0];
}

bool Morphology::Impl::_fromBinary(const void* data, const size_t size)
Morphology::Impl::Impl(const brion::Morphology& morphology)
: brion::plugin::MorphologyZeroEQ(morphology)
Copy link
Contributor

Choose a reason for hiding this comment

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

This inheritance doesn't neither look right to me at all.
First of all, ZeroEQ is an optional dependency. Given that, making a core class of Brain depend on something that has the ZeroEQ suffix doesn't only smell fishy, is already rotten. Maybe it's just the naming because I haven't reached the class declaration yet, but it could also be that inheritance is used where it should be aggregation.

, version(MORPHOLOGY_VERSION_H5_1_1)
, family(FAMILY_NEURON)
, version(v)
, family(f)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should throw when CellFamiliy is FAMILY_GLIA and the version is not 1.1. The old code was a bit strange exactly to prevent that from being possible at all.

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.

@@ -26,6 +27,7 @@ set(BRIONPLUGINS_SOURCES
compartmentReportMap.cpp
morphologyHDF5.cpp
morphologySWC.cpp
morphologyZeroEQ.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

The ZeroEQ sources should be added conditionally

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now yes, after the serialization code is factored out. Done.

const std::string path((const char*)data, size);
const brion::Morphology morphology(path);
const brion::plugin::MorphologyZeroEQ serializable{morphology};
return zeroeq::ReplyData(serializable.getTypeIdentifier(),
Copy link
Contributor

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 getTypeIdentifier(), it seems that it wouldn't match the code in the server application, where you use ZEROEQ_GET_MORPHOLOGY.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't match, but since it's ignored by the reply handler it does not matter. Fixed.

@eile
Copy link
Contributor Author

eile commented Aug 9, 2017

@rdumusc all: See last commit for a substantial cleanup in the internals. This breaks the API - shall I bump major?

eile pushed a commit to eile/Brion that referenced this pull request Aug 9, 2017
eile pushed a commit to eile/Brion that referenced this pull request Aug 9, 2017
eile pushed a commit to eile/Brion that referenced this pull request Aug 9, 2017
eile pushed a commit to eile/Brion that referenced this pull request Aug 9, 2017
eile pushed a commit to eile/Brion that referenced this pull request Aug 9, 2017
@eile eile force-pushed the zeromorph branch 6 times, most recently from 2b1bbf1 to f2f8f49 Compare August 23, 2017 13:53
@eile
Copy link
Contributor Author

eile commented Aug 24, 2017

Ping^2

Copy link
Contributor

@tribal-tec tribal-tec left a comment

Choose a reason for hiding this comment

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

Version bump to major 3?

eile pushed a commit to eile/Brion that referenced this pull request Aug 24, 2017
@eile
Copy link
Contributor Author

eile commented Aug 24, 2017

Version bump to major 3?

done

if (!loadFuture.valid())
return;

loadFuture.wait();
Copy link
Contributor

Choose a reason for hiding this comment

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

rm

eile pushed a commit to eile/Brion that referenced this pull request Aug 24, 2017
@eile eile merged commit 75a42bc into BlueBrain:master Aug 24, 2017
@eile eile deleted the zeromorph branch August 24, 2017 12:26
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.

None yet

4 participants