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

Add incomplete Sonata Circuit #222

Merged
merged 32 commits into from
Apr 25, 2018
Merged

Add incomplete Sonata Circuit #222

merged 32 commits into from
Apr 25, 2018

Conversation

karjonas
Copy link
Contributor

@karjonas karjonas commented Apr 6, 2018

It only has support for getPositions and getRotations so far.

@karjonas karjonas requested a review from hernando April 6, 2018 08:16
@@ -89,7 +93,7 @@ class ModelType:
"etype": ["fast", "slow", "fast"]}

writer = csv.writer(out, delimiter=' ',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
quotechar='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you have to add lineterminator

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 defaults to '\r\n' causing issues when parsing the csv file.

{
LBUNIMPLEMENTED;
return 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can implement this function also

return Strings();
}

virtual URI getMorphologyURI(const std::string& /*name*/) const
Copy link
Contributor

Choose a reason for hiding this comment

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

For this function I've just realized that you can almost share the same implementation for all subclasses. You need to add a new virtual function getMorphologySource to replace the _morphologySource member variable in the original implementation.

output.push_back(rotations[gid]);
return output;
}
virtual Strings getMorphologyNames(const GIDSet& /*gids*/) const
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be implemented


BOOST_AUTO_TEST_CASE(sonata_SonataConfig_constructors)
{
brain::Circuit circuit(TEST_SONATA_SIMPLE_NETWORK_URI);
Copy link
Contributor

@hernando hernando Apr 11, 2018

Choose a reason for hiding this comment

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

Check an exception is thrown if opening a json file which doesn't exist.

{
const auto& subnetworks = config.getNodes();
const auto& node = subnetworks.front();
brion::Nodes nodes(URI(basePath.string() + "/" + node.elements));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is wrong, you're assuming that paths are relative, which may not be the case.
The CircuitConfig should deal with all path substitutions and return absolute paths so client code doesn't need to deal with this stuff. As a matter of fact, I missed that you haven't dealt with relative paths at all in the CircuitConfig implementation.


if (subnetworks.size() > 1)
{
LBWARN << "More than one subnetwork found, ignored." << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

More than one subnetwork found, ignoring extra ones.

const auto populations = nodes.getPopulationNames();
if (populations.size() > 1)
{
LBWARN << "More than one population found, ignored." << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

if (nodeGroupIDs.size() > 1)
{
LBWARN << "More than one group ID found, ignored." << std::endl;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This dataset has as many elements as cells. You're always going to give a warning unless your circuit has 1 neuron.
What you must check is that all IDs are 0 and throw if there's any other value.

}

virtual URI getMorphologySource() const final { return morphologySource; }
virtual const brion::URI& getCircuitSource() const
Copy link
Contributor

Choose a reason for hiding this comment

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

The code for morphology caching needs to be reviewed. In principle I think this function should be renamed and return the circuit config .json path, but I have to think about it more carefully.


const auto names =
nodeGroup.getAttribute<std::string>("morphology_file", startIdx,
endIdx);
Copy link
Contributor

Choose a reason for hiding this comment

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

If this attribute doesn't exist, you have to look up in the CSV file based on the node type. This is exactly the case of ABI's circuits.

}
virtual Strings getMorphologyNames() const
{
return nodeGroup.getAttribute<std::string>("morphology_file");
Copy link
Contributor

Choose a reason for hiding this comment

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

UNIMPLEMENTED, the name is a bit misleading, it's not the morphology file names, it's the morphology type names. Which we don't have in ABI's circuits as far as I know.

}

expectedIdx++;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just compare nodeGroupIndices to a vector created with std::iota, it's shorter and it doesn't really matter which index is out of order because later we have to implement the indirect code.

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 do not understand how to do that so I will leave like this since we are removing it anyway

@@ -222,12 +189,335 @@ class Circuit::Impl

URI getMorphologyURI(const std::string& name) const
{
URI uri(_morphologySource);
URI uri(getMorphologySource());
Copy link
Contributor

Choose a reason for hiding this comment

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

This is incorrect, but leave it like that I'll fix it later.

Copy link
Contributor

@hernando hernando left a comment

Choose a reason for hiding this comment

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

It's mostly OK, I'll take care of the remaining changes.

@@ -214,20 +183,384 @@ class Circuit::Impl

virtual Vector3fs getPositions(const GIDSet& gids) const = 0;
virtual size_ts getMTypes(const GIDSet& gids) const = 0;
virtual Strings getMorphologyNames() const = 0;
virtual Strings getMorphologyTypeNames() const = 0;
virtual size_ts getETypes(const GIDSet& gids) const = 0;
virtual Strings getElectrophysiologyNames() const = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename this one also for consistency

if (boost::filesystem::path(name).is_absolute())
return URI(name);

URI uri(getMorphologySource());
uri.setPath(uri.getPath() + "/" + name + ".h5");
return uri;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll review this and change it myself. I will commit on top of your branch head.

virtual const brion::Synapse* getSynapseExtra() const = 0;
virtual const brion::Synapse& getSynapsePositions(
const bool afferent) const = 0;
virtual const URI& getSynapseSource() const = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'm going to do another some other refactorings here also. This design is looking terrible to me. This will also remove the need for the compilation hacks you made below.

const auto attributeNames = nodeGroup.getAttributeNames();
const bool hasMorpholgyFile =
std::find(attributeNames.begin(), attributeNames.end(),
propertyName) != attributeNames.end();
Copy link
Contributor

Choose a reason for hiding this comment

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

What about adding a function to search for an attribute name in NodeGroup?

@hernando
Copy link
Contributor

retest this please

@hernando
Copy link
Contributor

Retest this please

Renamed namespace of hlohmann::json to brion_nlohmann to prevent
conflicts with tools linking to Brion and using a different version.
@hernando hernando merged commit d9e1352 into BlueBrain:master Apr 25, 2018
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

2 participants