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

Add GitHub Codespaces support #81

Merged
merged 9 commits into from
Feb 8, 2024
Merged

Conversation

diegoferigo
Copy link
Member

@diegoferigo diegoferigo commented Feb 7, 2024

This PR adds the bare minimum resources to obtain a GitHub Codespace with the following features:

  • Docker container based on Ubuntu.
  • Python environment with all the JAXsim dependencies installed in a conda environment.
  • Capable of navigating the Python project.
  • Support of autocompletion.

This should help the process of on-the-fly editing and reviewing.


Here below further details:

  • The base image in which VSCode runs is the latest LTS as documented here.
  • The initial devcontainer.json was taken by this template.
  • The conda environment is created by enabling the micromamba feature (you can find here the complete list of features). It requires extending the base image if the environment is created from a yaml file as in our case.
  • I used and slightly modified the yaml file originally added by @flferretti for ReadTheDocs, moving it to the top-level. As a consequence, the repo now supports other web tools that search for top-level environment files (like binder).
  • I enabled, for now, only the official Python extension.

The steps to open a codespace is the following:

  1. Open the desired branch in the github repository.
  2. Click the green button Code > Create workspace in devcontainer.
  3. The image is built and the container is started.
  4. As soon as VSCode shows up, the terminal in the bottom should already have the jaxsim conda environment generated from the yaml file ready and active (check which python).
  5. Wait a few seconds more to let VSCode finish the installation of the active extensions.
  6. Open any Python file, and in the bottom-right corner select the Python 3.11 interpreter. By default, it detects the system interpreter.

Now the project is ready to be navigated. It is not necessary to install the project in editable mode if no code needs to be executed. VSCode automatically detects the sources in src/ and Ctrl+click should work fine. Otherwise, to e.g. run any code (tests included), the project can be installed as follows:

pip install --no-deps -e .

Other notes:

Running the tests now fail due to:

ImportError while importing test module '/workspaces/jaxsim/tests/test_eom.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/conda/envs/jaxsim/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_eom.py:11: in <module>
    from . import utils_idyntree, utils_models, utils_rng
tests/utils_idyntree.py:5: in <module>
    import idyntree.bindings as idt
/opt/conda/envs/jaxsim/lib/python3.11/site-packages/idyntree/__init__.py:1: in <module>
    from . import swig
/opt/conda/envs/jaxsim/lib/python3.11/site-packages/idyntree/swig.py:10: in <module>
    from . import _iDynTree
E   ImportError: libGL.so.1: cannot open shared object file: No such file or directory

I'm not interested to fix this at this stage. cc FYI @traversaro, likely I need to install some missing system dependency or GL support in the conda environment.


📚 Documentation preview 📚: https://jaxsim--81.org.readthedocs.build//81/

@diegoferigo diegoferigo force-pushed the devcontainer branch 2 times, most recently from d036090 to 13f7623 Compare February 7, 2024 13:45
@diegoferigo diegoferigo marked this pull request as ready for review February 7, 2024 13:54
@traversaro
Copy link
Contributor

FYI @traversaro, likely I need to install some missing system dependency or GL support in the conda environment.

Yes, this is due to https://conda-forge.org/docs/maintainer/knowledge_base.html#libgl . Unfortunatly there there is no docs on which apt packages should be installed, but via apt-file:

traversaro@IITBMP014LW012:~$ apt-file search libGL.so.1
libgl1: /usr/lib/x86_64-linux-gnu/libGL.so.1
libgl1: /usr/lib/x86_64-linux-gnu/libGL.so.1.7.0
nsight-compute: /usr/lib/nsight-compute/host/linux-desktop-glibc_2_11_3-x64/Mesa/libGL.so.1
nsight-compute: /usr/lib/nsight-compute/host/linux-desktop-glibc_2_11_3-x64/Mesa/libGL.so.1.5.0
nsight-systems: /usr/lib/nsight-systems/host-linux-x64/Mesa/libGL.so.1
nsight-systems: /usr/lib/nsight-systems/host-linux-x64/Mesa/libGL.so.1.5.0
primus-libs: /usr/lib/x86_64-linux-gnu/primus/libGL.so.1

so I guess sudo apt install libgl1 should be ok.

Copy link
Collaborator

@flferretti flferretti left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@traversaro
Copy link
Contributor

Thanks! For reference I was worried about possible billing for the ami-iit organization, but after reading https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/choosing-who-owns-and-pays-for-codespaces-in-your-organization we should be good to go (we have a 0€ limit for Codespaces).

@diegoferigo
Copy link
Member Author

so I guess sudo apt install libgl1 should be ok

Yep I can confirm that libgl1 is the bare minimum required.

I was worried about possible billing for the ami-iit organization

Good point, I didn't think of billings. How does it work, do we have some free hours included? I just checked my personal account since I was originally thinking that it would have consumed my free hours, but it seems that I didn't consume any.

Screenshot_20240207_221201

@traversaro
Copy link
Contributor

Good point, I didn't think of billings. How does it work, do we have some free hours included?

I don't think so, there is a " A $0 limit will prevent your organization from using Codespaces " notice under the limit.

@diegoferigo
Copy link
Member Author

Good point, I didn't think of billings. How does it work, do we have some free hours included?

I don't think so, there is a " A $0 limit will prevent your organization from using Codespaces " notice under the limit.

Ok, if we start facing any problem I guess we can change the settings at that time. Here I found the following:

If an organization chooses for codespaces to be user-owned, a user who creates a codespace from a repository in the organization always pays for the codespace. The user's access to create codespaces depends on the visibility of the repository and your organization's access settings.

Since we all can get a Pro account within AMI, switching to user-owned codespaces might be the best choice - if it's not already the case.

@diegoferigo diegoferigo changed the title Add GitHub Codespace support Add GitHub Codespaces support Feb 8, 2024
@diegoferigo diegoferigo merged commit f4d8318 into ami-iit:main Feb 8, 2024
11 checks passed
@diegoferigo diegoferigo deleted the devcontainer branch February 8, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants