Skip to content
Snippets Groups Projects

Draft: F fix get parents

Open Henrik tom Wörden requested to merge f-fix-get-parents into dev

Summary

This is a fix for #157 .

The other functions in caosdb.js need to be checked for similar problems.

This was implemented by @salexan a while ago.

Test Environment

How to set up a test environment for manual testing?

Check List for the Author

Please, prepare your MR for a review. Be sure to write a summary and a focus and create gitlab comments for the reviewer. They should guide the reviewer through the changes, explain your changes and also point out open questions. For further good practices have a look at our review guidelines

  • All automated tests pass
  • Reference related Issues
  • Up-to-date CHANGELOG.md
  • Annotations in code (Gitlab comments)
    • Intent of new code
    • Problems with old code
    • Why this implementation?

Check List for the Reviewer

  • I understand the intent of this MR
  • All automated tests pass
  • Up-to-date CHANGELOG.md
  • The test environment setup works and the intended behavior is reproducible in the test environment
  • In-code documentation and comments are up-to-date.
  • Check: Are there spezifications? Are they satisfied?

For further good practices have a look at our review guidelines.

Edited by Henrik tom Wörden

Merge request reports

Pipeline #9311 passed

Pipeline passed for 41274920 on f-fix-get-parents

Ready to merge by members who can write to the target branch.
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Henrik tom Wörden changed the description

    changed the description

  • Henrik tom Wörden added 234 commits

    added 234 commits

    Compare with previous version

  • Henrik tom Wörden marked this merge request as draft from 99d84516

    marked this merge request as draft from 99d84516

  • Henrik tom Wörden changed target branch from dev to f-boot-tour

    changed target branch from dev to f-boot-tour

  • Timm Fitschen deleted the f-boot-tour branch. This merge request now targets the dev branch

    deleted the f-boot-tour branch. This merge request now targets the dev branch

  • added 38 commits

    Compare with previous version

  • added 4 commits

    Compare with previous version

  • Here is a small script to setup a test environment for testing the fix:

    #!/bin/python
    # Setup a small environment for testing the bug behavior.
    # A. Schlemmer, 06/2021
    
    import caosdb as db
    
    rt1 = db.RecordType(name="TypeA")
    rt2 = db.RecordType(name="TypeB")
    
    r1 = db.Record(name="Test_R_1")
    r1.add_parent(rt1)
    
    r2 = db.Record(name="Test_R_2")
    r2.add_parent(rt2)
    r2.add_property(rt1, value=r1)
    
    c = db.Container().extend([rt1, rt2, r1, r2])
    c.insert()
    
  • Checklist of possibly affected functions in caosdb.js:

    • getParents <- affected
    • getEntityDescription <- unaffected
    • getEntitySize <- unaffected
    • getEntityChecksum <- unaffected
    • getEntityPath <- unaffected
    • getEntityName <- affected
    • getEntityDatatype <- affected
    • getEntityUnit <- unaffected
    • getEntityRole <- affected

    A check mark means: Either it is not affected or it was fixed.

    Edited by Alexander Schlemmer
  • Here is an expanded script, to test variants of the problem:

    #!/bin/python
    # Setup a small environment for testing the bug behavior.
    # A. Schlemmer, 06/2021
    
    import caosdb as db
    
    rt1 = db.RecordType(name="TypeA", description="11 The first type")
    rt2 = db.RecordType(name="TypeB", description="22 The second type")
    
    r1 = db.Record(name="Test_R_1", description="33 A record for the first type")
    r1.add_parent(rt1)
    
    f1 = db.File(name="Test A cool file", path="/test.txt", file="test.txt")
    f2 = db.File(name="Test Another cool file", path="/testfile2.txt", file="testfile2.txt")
    
    p1 = db.Property(name="TestFileProperty", datatype=db.FILE)
    p2 = db.Property(name="TestDoubleProperty", datatype=db.DOUBLE, unit="m")
    p3 = db.Property(name="TestIntegerProperty", datatype=db.INTEGER, unit="s")
    
    p4 = db.Property(name="TestReferenceProperty", datatype=rt2)
    
    r2 = db.Record(name="Test_R_2", description="44 A second record for the second type")
    r2.add_parent(rt2)
    r2.add_property(rt1, value=r1)
    r2.add_property(p1, value=f1)
    r2.add_property(p2, value=24.8)
    r2.add_property(p3, value=1)
    
    f2.add_property(p1, value=f1)
    p2.add_property(p3, value=27)
    
    p2.add_property(p4, value=r2)
    
    c = db.Container().extend([rt1, rt2, r1, r2, f1, p1, p2, p3, f2, p4])
    c.insert()
    
    b = input("Press any key to cleanup.")
    c.delete()
  • @henrik @florian I checked whether other functions in caosdb.js are affected from similar issues. See above. I suggest creating three new issues for the remaining problems and merging this merge request, as it resolves many problems related to parents already. What do you think?

    I furthermore recommend a review of the functions in caosdb.js as I noticed some inconsistencies that should be repaired and also reflect recent changes in the webui layout and design.

  • mentioned in issue #226

  • mentioned in issue #227

  • mentioned in issue #228

  • mentioned in issue #229

  • I created 4 corresponding issues.

    • @timm Could you provide an example for me, how I can write a unit test for testing preview related functions?

    • I don't know the details by heart but the idea is the following:

      1. Copy an html string of an entity with an open preview (which has a parent you want to "miss") from a caosdb webui (e.g. locally started linkahead with your test data).
      2. Strip away any unnecessary stuff (The more you can strip away from the string the better you can read that example later on, obviously).
      3. Create a document in the test with test_entity = xml2str(example_str);,
      4. then throw your function under test on that html document getParents(test_entity) and
      5. check the results.
    • Please register or sign in to reply
  • @timm Yes, that sounds reasonable. But the hard part is: How to generate the preview for the generated container on-the-fly without having to use the full preview.js module including retrieval of referenced entities. Do you have a simple idea how to do that?

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading