Skip to content
This repository was archived by the owner on Nov 9, 2019. It is now read-only.

ImmutableComputableGraph code improvement + unit tests - #1042

Open
mbabadi wants to merge 1 commit into
masterfrom
mb_ICG_refactoring_and_tests
Open

ImmutableComputableGraph code improvement + unit tests#1042
mbabadi wants to merge 1 commit into
masterfrom
mb_ICG_refactoring_and_tests

Conversation

@mbabadi

@mbabadi mbabadi commented May 16, 2017

Copy link
Copy Markdown
Contributor
  • reviewed and restricted the access modifiers of all ICG-related classes
  • got rid of the functionality to hold on to old caches: whenever a cache goes out of date, the reference is immediately made null in the new ICG
  • completely rewrote ComputableGraphStructure in a functional style
  • got rid of unused and unnecessary methods
  • Created an ImmutableComputableGraphUtils and factored out the builder and other common methods
  • math equality asserts for NDArray
  • unit tests for ComputableGraphStructure
  • unit tests for ImmutableComputableGraph
  • unit tests for ImmutableComputableGraphUtils

@mbabadi

mbabadi commented May 16, 2017

Copy link
Copy Markdown
Contributor Author

@samuelklee can you suggest a reviewer? this is smaller than it seems :)

@samuelklee

samuelklee commented May 17, 2017

Copy link
Copy Markdown
Contributor

@asmirnov239, perhaps you can take a look after you issue the PR for the germline WDL? Otherwise I will take it when I get back, if you don't get to it by then.

@asmirnov239

Copy link
Copy Markdown
Contributor

Yes sure! I can review it after I come back Wednesday next week

@asmirnov239 asmirnov239 self-assigned this May 25, 2017

@asmirnov239 asmirnov239 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mbabadi Looks great! Back to you

*/
public ComputableCacheNode duplicateWithUpdatedValue(final Duplicable newValue) {
if (cacheEvals && newValue != null && !newValue.hasValue()) {
ComputableCacheNode duplicateWithUpdatedValue(final Duplicable newValue) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing @Override annotation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch! done.

* - topological order for evaluating all nodes associated to a tag (see {@link ImmutableComputableGraph}).
* - assertion for existence of no cycles
* - construction of maps of nodes to their descendants and ancestors
* - propagation of tags from descendants to ancestors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a description, or a link to a description of what tag is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

* - topological order for evaluating a computable node
* - topological order for mutating a primitive/externally-computed node and updating the caches of all involved nodes
* - topological order for evaluating all nodes associated to a tag (see {@link ImmutableComputableGraph})
* - topological order for complete computation of the graph

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

topological order for complete computation of the graph -> topological order for evaluating all nodes in the graph

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

nodeTagsSet = extractTags(nodeSet);
assertParentKeysExist(nodeSet, nodeKeysSet);

/* nodeKey -> set of parents' keys */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would move this description to the instance variable definition or the getter methods

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sounds good.

/* nodeKey -> set of parents' keys */
parentsMap = getParentsMap(nodeSet);

/* nodeKey -> set of children's keys */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same goes here, and for everything else below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

private static final Map<String, Duplicable> EMPTY_PARENTS = new HashMap<>();

/**
* Instructions for computing f(x, y) = F[2] ( F[0](x), F[1](x) )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it should be F[2] ( F[0](x), F[1](y) )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, typo -- fixed.

Assert.assertTrue(!icg_tmp.isValueDirectlyAvailable("h"));
assertIntactReferences(icg_0, icg_tmp, "y", "z", "g");

ImmutableComputableGraph icg_tmp_old = icg_tmp;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why declare another reference?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we discussed this

* Tests propagation of tags from descendents to parents
*/
@Test(dataProvider = "allPossibleNodeFlags", invocationCount = NUM_TRIALS)
public void testTagPropagation(final boolean f_caching, final boolean f_external,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this belong to ComputableGraphStructureUnitTest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test is actually redundant given the tests in ComputableGraphStructureUnitTest but I thought of keeping it because it is a concrete test for the concrete ICG worked out in this unit test. It may help some person in the future to understand what tag propagation means, etc.

* Asserts that the equality comparison of two {@link CacheNode}s is done just based on their key
*/
@Test
public void testEquality() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test should go into the corresponding CacheNode unit test

@Test(enabled = false)
public void testPrimitiveUpdating() {
throw new AssertionFailedError("Test is not implemented yet");
@Test(expectedExceptions = UnsupportedOperationException.class)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here as above, and also for the tests below

@asmirnov239 asmirnov239 assigned mbabadi and unassigned asmirnov239 May 31, 2017
@droazen

droazen commented Jun 2, 2017

Copy link
Copy Markdown
Contributor

- reviewed and restricted the access modifiers of all ICG-related classes
- got rid of the functionality to hold on to old caches: whenever a cache goes out of date, the reference is immediately made null in the new ICG
- completely rewrote ComputableGraphStructure in a functional style
- got rid of unused and unnecessary methods
- Created an ImmutableComputableGraphUtils and factored out the builder and other common methods
- math equality asserts for NDArray
- unit tests for ComputableGraphStructure
- unit tests for ImmutableComputableGraph
- unit tests for ImmutableComputableGraphUtils
- keys and tags have their own classes now
@mbabadi

mbabadi commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

@asmirnov239 OK, done with the review! :) I addressed all of your comments except for one (concrete example for graph structure). Will move to main repo and merge after the tests pass.

@mbabadi
mbabadi force-pushed the mb_ICG_refactoring_and_tests branch from d6a5bdf to 8282bd4 Compare June 6, 2017 06:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants