gazebosim / gz-mujoco

25 stars 4 forks source link

Restructure package (Alternative to #39) #74

Closed azeey closed 2 years ago

azeey commented 2 years ago

πŸŽ‰ New feature

Summary

After testing #39, I'm more convinced that it would be easier to put everything inside one python package. Last time I tried #39, I think I was having issues with imports.

The proposed package layout looks like:

.
└── sdformat_mjcf
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ mjcf_to_sdformat
    β”‚Β Β  └── __init__.py
    β”œβ”€β”€ sdformat_to_mjcf
    β”‚Β Β  └── __init__.py
    └── utils

Where we have sdformat_mjcf as the top level package. For the directory structure for for the distribution package (gz-mujoco/sdformat_mjcf), I opted to use the src layout as encouraged in the pytest good practices page and explained in this blog. The advantage of the src layout is that our tests always test what's installed, not what's in the src directory.

In addition to shuffling files and fixing imports, I made a change to how TEST_RESOURCE_DIR is computed. This was necessary because the way we had it before, __file__ was being evaluated in the context of the importing module and so, was dependent on the location of the importing module. The intended behavior was that __file__ would always evaluate to the location of the helper.py module.

Test it

All existing tests should pass.

Checklist

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

codecov[bot] commented 2 years ago

Codecov Report

Merging #74 (c220e91) into main (a454f3d) will increase coverage by 1.41%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #74      +/-   ##
==========================================
+ Coverage   97.43%   98.84%   +1.41%     
==========================================
  Files          19       21       +2     
  Lines         896     1992    +1096     
==========================================
+ Hits          873     1969    +1096     
  Misses         23       23              
Impacted Files Coverage Ξ”
.../mjcf_to_sdformat/test_add_mjcf_geometry_to_sdf.py 99.23% <100.00%> (ΓΈ)
...sts/mjcf_to_sdformat/test_add_mjcf_light_to_sdf.py 98.24% <100.00%> (ΓΈ)
...mjcf_to_sdformat/test_add_mjcf_worldbody_to_sdf.py 99.53% <100.00%> (ΓΈ)
...ormat_mjcf/tests/mjcf_to_sdformat/test_defaults.py 98.82% <100.00%> (ΓΈ)
...t_mjcf/tests/mjcf_to_sdformat/test_force_torque.py 98.14% <100.00%> (ΓΈ)
sdformat_mjcf/tests/mjcf_to_sdformat/test_imu.py 98.14% <100.00%> (ΓΈ)
...ests/mjcf_to_sdformat/test_mjcf_material_to_sdf.py 98.48% <100.00%> (ΓΈ)
.../tests/mjcf_to_sdformat/test_mjcf_sensor_to_sdf.py 98.24% <100.00%> (ΓΈ)
...t_mjcf/tests/sdformat_to_mjcf/test_add_geometry.py 99.43% <100.00%> (ΓΈ)
...rmat_mjcf/tests/sdformat_to_mjcf/test_add_joint.py 99.43% <100.00%> (ΓΈ)
... and 51 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 a454f3d...c220e91. Read the comment docs.