-
Notifications
You must be signed in to change notification settings - Fork 22
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
Conversation
7effdd2
to
00cb7b3
Compare
Retest this please. |
12d03eb
to
e9e2cb6
Compare
ping? |
brain/CMakeLists.txt
Outdated
) | ||
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) |
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.
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.
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.
done
brion/plugin/morphologyZeroEQ.h
Outdated
{ | ||
namespace plugin | ||
{ | ||
class MorphologyZeroEQ : public MorphologyPlugin, public servus::Serializable |
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 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.
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.
Let me see what I can do. It's both a serializable morphology (for brain & ZeroEQ) and the ZeroEQ plugin.
brain/neuron/morphologyImpl.cpp
Outdated
@@ -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) |
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.
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...
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.
^ see above. Likely I'll move the serializable morphology to a helper class.
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.
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.
tests/perf/circuit.cpp
Outdated
BOOST_AUTO_TEST_CASE(load_morphologies) | ||
{ | ||
const brain::Circuit circuit( | ||
(brion::URI("/home/eilemann/stable/Brion/BlueConfig"))); |
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.
home folder path? What happens if someone runs ninja Brion-perftests?
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.
Accidental testing artefact. Fixed.
tests/perf/circuit.cpp
Outdated
const brain::Circuit circuit( | ||
(brion::URI("/home/eilemann/stable/Brion/BlueConfig"))); | ||
auto gids = circuit.getGIDs(); | ||
if (gids.size() > 50000) |
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.
make this a function, something like:
resizeIfBiggerThan(gids, 50000);
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.
o_O
apps/CMakeLists.txt
Outdated
@@ -24,6 +24,13 @@ if(TARGET BBPTestData) | |||
list(APPEND SPIKECONVERTER_LINK_LIBRARIES BBPTestData) | |||
endif() | |||
|
|||
if(TARGET ZeroEQ) | |||
set(MORPHOLOGYSERVER_HEADERS) |
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.
Remove if empty.
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.
done
@@ -24,6 +24,13 @@ if(TARGET BBPTestData) | |||
list(APPEND SPIKECONVERTER_LINK_LIBRARIES BBPTestData) | |||
endif() | |||
|
|||
if(TARGET ZeroEQ) |
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.
Keyv is also optional
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.
common_find_package(Keyv REQUIRED) ?
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.
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); |
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.
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?
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 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.
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.
That was not obvious by the code because in case of errors you're returning and empty reply.
apps/morphologyServer.cpp
Outdated
<< " 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: " |
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 like u better that D for disk read uncached. So can rewrite it as [u]ncached disk read
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.
done
apps/morphologyServer.cpp
Outdated
#include <brion/morphology.h> | ||
#include <brion/plugin/morphologyZeroEQ.h> | ||
#include <keyv/Map.h> | ||
#include <lunchbox/daemon.h> |
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 used
brain/circuit.cpp
Outdated
brion::Morphology& raw = loading.find(hash)->second; | ||
neuron::MorphologyPtr morphology( | ||
transform ? new neuron::Morphology(raw, transforms[i]) | ||
: new neuron::Morphology(raw)); |
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're not updating cached anymore, well, yes, with a nullptr above.
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.
good catch. Fixed.
brain/neuron/morphologyImpl.cpp
Outdated
@@ -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) |
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.
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) |
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.
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.
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.
done.
brion/plugin/CMakeLists.txt
Outdated
@@ -26,6 +27,7 @@ set(BRIONPLUGINS_SOURCES | |||
compartmentReportMap.cpp | |||
morphologyHDF5.cpp | |||
morphologySWC.cpp | |||
morphologyZeroEQ.cpp |
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.
The ZeroEQ sources should be added conditionally
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.
Now yes, after the serialization code is factored out. Done.
tests/morphology.cpp
Outdated
const std::string path((const char*)data, size); | ||
const brion::Morphology morphology(path); | ||
const brion::plugin::MorphologyZeroEQ serializable{morphology}; | ||
return zeroeq::ReplyData(serializable.getTypeIdentifier(), |
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 getTypeIdentifier(), it seems that it wouldn't match the code in the server application, where you use ZEROEQ_GET_MORPHOLOGY.
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 doesn't match, but since it's ignored by the reply handler it does not matter. Fixed.
@rdumusc all: See last commit for a substantial cleanup in the internals. This breaks the API - shall I bump major? |
2b1bbf1
to
f2f8f49
Compare
Ping^2 |
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.
Version bump to major 3?
done |
brion/morphology.cpp
Outdated
if (!loadFuture.valid()) | ||
return; | ||
|
||
loadFuture.wait(); |
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.
rm
No description provided.