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

Fix #6720 - Objects with different names will trigger a "Duplicate Name" Error in JSON #7036

Merged
merged 13 commits into from
Nov 13, 2018

Conversation

jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Oct 26, 2018

Pull request overview

Fix #6720 duplicate name json

Issue was a problem in doj/alphanum.hpp when you have leading zeros. Basically it computes a number for the left side, and another for right side, and compares that. But that means "01" and "001" end up being the same, so it reports them as being equal. Adding a clause where when diff is zero, you also check the length of the left and right sides, and potentially return that.

Added unit tests, that fail without the fix (see https://github.com/jmarrec/EnergyPlus/tree/Do_Not_Publish/6720_UnitTestOnly) and work with it.

Rationale for leading zeroes

I had to made a choice for the case where you have leading zeroes as I couldn't really find any information online: I assume that if you have two strings, "n_001" and "n_1", I assume you want "n_001" < "n_1" (behavior is easy to change if you disagree)

Work Checklist

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • At least one of the following appropriate labels must be added to this PR to be consumed into the changelog:
    • Defect: This pull request repairs a github defect issue. The github issue should be referenced in the PR description
    • Refactoring: This pull request includes code changes that don't change the functionality of the program, just perform refactoring
    • NewFeature: This pull request includes code to add a new feature to EnergyPlus
    • Performance: This pull request includes code changes that are directed at improving the runtime performance of EnergyPlus
    • DoNoPublish: This pull request includes changes that shouldn't be included in the changelog

Review Checklist

This will not be exhaustively relevant to every PR.

  • Functional code review (it has to work!)
  • If defect, results of running current develop vs this branch should exhibit the fix
  • CI status: all green or justified
  • Performance: CI Linux results include performance check
  • Unit Test(s)
  • C++ checks:
    • Argument types
    • If any virtual classes, ensure virtual destructor included, other things
  • IDD changes:
    • Verify naming conventions and styles, memos and notes and defaults
    • Open windows IDF Editor with modified IDD to check for errors
    • If transition, add to input rules file for interfaces
    • If transition, add transition source
    • If transition, update idfs
  • If new idf included, locally check the err file and other outputs
  • Required documentation updates?
  • ExpandObjects changes?
  • If output changes, including tabular output structure, add to output rules file for interfaces

@jmarrec jmarrec added the Defect Includes code to repair a defect in EnergyPlus label Oct 26, 2018
@jmarrec jmarrec changed the title Fix #6720 duplicate name json Fix #6720 - Objects with different names will trigger a "Duplicate Name" Error in JSON Oct 26, 2018
@Myoldmopar
Copy link
Member

@jmarrec could you pull develop into this branch and see if the test failures were due to a CI thing or if this branch actually breaks everything?

@jmarrec
Copy link
Contributor Author

jmarrec commented Nov 9, 2018

@Myoldmopar done.

Even though I push to my remote, any maintainer has write access to it so feel free to do that kind of stuff.

If that's easier I could push to NREL/EnergyPlus in the future instead if you prefer (but that increases the attention needed to delete merge branches though in order to not clutter everything).

@Myoldmopar
Copy link
Member

@jmarrec so this is causing lots of issues. Our CI bots are failing (panicking on Linux...) due to bad allocations as they run out of memory. Something has gone very awry with this. I need to close this PR so that our CI machines don't continue to try to run.

@mjwitte this is the cause of the memory issue I saw which caused me to ramp down the number of processors on the Linux machine. I'll be ramping it back up now...

@Myoldmopar
Copy link
Member

Oh, I kinda left that open-ended. @jmarrec please continue to investigate this, but again, I'm closing this PR so our CI machines won't continue trying to build it.

@Myoldmopar Myoldmopar closed this Nov 11, 2018
@jmarrec
Copy link
Contributor Author

jmarrec commented Nov 12, 2018

@Myoldmopar I caught a tiny mistake in the alphanum stuff (my bad, copy paste error).
I built on Ubuntu and didn't get any problems running the test (but then again, neither did I before). I also built on Windows just now and was able to run the tests as well.

Could we try the linux CI bots again?

@jmarrec jmarrec reopened this Nov 12, 2018
@Myoldmopar
Copy link
Member

CI is slightly happier with this branch now 🙃 👍

I'll take a look at this one today.

Copy link
Contributor

@mbadams5 mbadams5 left a comment

Choose a reason for hiding this comment

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

The changes are appropriate in the alphanum library and there are good unit tests for this bug.


/* $Header: /code/doj/alphanum.hpp,v 1.3 2008/01/28 23:06:47 doj Exp $ */


// MODIFIED: Julien Marrec, EffiBEM, on 2018-10-26 to avoids "n_001" being recognized as the same as "n_01"
Copy link
Contributor

Choose a reason for hiding this comment

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

Typically we haven't been adding attribution/bug issue comments like this in new E+ code and especially in third party libraries.

};

// This all works just fine
test("Standard insulation");
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting use of lambda's in the unit test. Seems like it might be overkill for this unit test, but I can think of other unit tests where this approach may come in handy for sure.

Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

@jmarrec I'm going to push a comment-only commit and merge this in. Thanks!

// Add the first material to it
root[obj_name][name1] = mat1;

auto test = [=](std::string search_name) {
Copy link
Member

Choose a reason for hiding this comment

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

@jmarrec it seems odd to put a lambda in here as opposed to making another function, but it's OK with me.


/* $Header: /code/doj/alphanum.hpp,v 1.3 2008/01/28 23:06:47 doj Exp $ */


// MODIFIED: Julien Marrec, EffiBEM, on 2018-10-26 to avoids "n_001" being recognized as the same as "n_01"
Copy link
Member

Choose a reason for hiding this comment

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

@jmarrec it's important to track our changes to third_party libraries, but I don't like comments as the mechanism. These can easily get overridden when we bring in a new version of the library. I'm going to transform this comment into the start of a new file at third_party/PATCHES.md where we'll keep track of all the changes we make to third_party libraries.

@Myoldmopar Myoldmopar merged commit 022bd03 into NREL:develop Nov 13, 2018
@jmarrec
Copy link
Contributor Author

jmarrec commented Nov 13, 2018

I’m still learning the E+ coding style so please continue to flag unusual stuff like this (and please excuse said unusual stuff, I don’t do it on purpose!).

As for the use of lambda here, it’s a short code block that wouldn’t be used by any other test (but I hate repeating myself) so I thought a lambda made sense here. (And I guess I could have cleaned it up a bit though)

@jmarrec jmarrec deleted the PR_opened/Fix_6720_DuplicateNameJSON branch November 20, 2018 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON validation duplicate name problem
6 participants