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

Major refactoring of the Kubric internals #54

Merged
merged 9 commits into from
Sep 2, 2020
Merged

Conversation

Qwlouse
Copy link
Collaborator

@Qwlouse Qwlouse commented Aug 26, 2020

The main interface of Kubric now builds on the traitlets package.

The idea is that for things like 3D objects or lights, there are corresponding classes in core.py.
They define traits for controllable parameters such as position or color.
Both PyBullet and Blender then register observers for those traits such that every change to that object is mirrored in simulation and rendering.

@Qwlouse Qwlouse requested a review from taiya August 26, 2020 16:49
@googlebot googlebot added the cla: yes Used by the SignCLA bot label Aug 26, 2020
@codecov-commenter
Copy link

codecov-commenter commented Aug 26, 2020

Codecov Report

Merging #54 into master will increase coverage by 13.39%.
The diff coverage is 23.73%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #54       +/-   ##
===========================================
+ Coverage    1.86%   15.26%   +13.39%     
===========================================
  Files          13       19        +6     
  Lines        1070     1363      +293     
===========================================
+ Hits           20      208      +188     
- Misses       1050     1155      +105     
Impacted Files Coverage Δ
kubric/assets/asset_source.py 0.00% <0.00%> (ø)
kubric/assets/klevr.py 0.00% <0.00%> (ø)
kubric/core.py 0.00% <0.00%> (ø)
kubric/simulator.py 0.00% <0.00%> (ø)
kubric/viewer/blender.py 0.00% <0.00%> (ø)
worker.py 0.00% <0.00%> (ø)
kubric/traits.py 84.61% <84.61%> (ø)
kubric/color.py 91.42% <91.42%> (ø)
test/test_color.py 100.00% <100.00%> (ø)
test/test_traits.py 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b7fd7a...42e5878. Read the comment docs.

@Qwlouse
Copy link
Collaborator Author

Qwlouse commented Sep 1, 2020

@taiya Did you have a chance to look at this already? I would like to merge this PR soon, since it touches so much of the codebase and thus impacts all further development.

@taiya
Copy link
Collaborator

taiya commented Sep 1, 2020

Sorry, perf+promo delayed me quite a lot.
I was planning to review it this afternoon.

1 similar comment
@taiya
Copy link
Collaborator

taiya commented Sep 1, 2020

Sorry, perf+promo delayed me quite a lot.
I was planning to review it this afternoon.

Copy link
Collaborator

@taiya taiya left a comment

Choose a reason for hiding this comment

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

Massive PR, so it was hard to cover everything; overall:

  • use of traitlets → 👍
  • removing double inheritance → 👍
  • AttributeSetter → 👎 (not sure I enjoy the added logic)

For the latter (update of extra properties), I just wonder whether a simpler solution exists.

Further, having to do Blender(scene) (as opposed to inheritance) don't you immediately lose the "immediate render" mode? (more precisely, for blender it is immediate write to file, for THREEJS is actual immediate render)

Anyhow, as this is blocking you, and the internals are something we can improve over time, I'll approve.
Please see comments and auto-resolve/merge

worker.py Outdated Show resolved Hide resolved
worker.py Outdated Show resolved Hide resolved
worker.py Outdated Show resolved Hide resolved
worker.py Outdated Show resolved Hide resolved
worker.py Show resolved Hide resolved
kubric/core.py Show resolved Hide resolved
kubric/core.py Show resolved Hide resolved
def __init__(self, target_obj, target_name):
self.target_name = target_name
self.target_obj = target_obj
self.mapping = None # has to be set by the add() function
Copy link
Collaborator

Choose a reason for hiding this comment

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

add? not a member of this class? → confusde

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this is a bit ugly. It refers to the add() functions of the simulator / renderer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

k, then it needs to be documented properly

gravity = kt.Vector3D(default_value=(0, 0, -10.))


class AttributeSetter:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be here or in blender.py until it's used by multiple backends?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could move it there, though I am not sure in what way that would be better.
I intended to also use it for the simulator, but I ended up having to write specialised setters because pybullet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's revisit this once we discuss the setters in detail

kubric/simulator.py Show resolved Hide resolved
@Qwlouse
Copy link
Collaborator Author

Qwlouse commented Sep 2, 2020

Great, thanks for the feedback @taiya!
I fixed many of the minor issues you flagged, and I tried to answer most of the questions. So as you suggested, I will merge now, but let's keep discussing the broader points you raised.

@Qwlouse Qwlouse merged commit af33c5d into master Sep 2, 2020
@Qwlouse Qwlouse deleted the klausg_refactor branch January 19, 2021 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Used by the SignCLA bot
Development

Successfully merging this pull request may close these issues.

None yet

4 participants