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 devcontainer #1085

Merged
merged 18 commits into from
Mar 2, 2024
Merged

Conversation

julien-blanchon
Copy link
Contributor

Add .devcontainer directory with basic working devcontainer

@adamjstewart
Copy link
Collaborator

What is this and why would we want it?

@adamjstewart
Copy link
Collaborator

How is this different from #367/#368 which was rejected?

@julien-blanchon
Copy link
Contributor Author

Hi, devcontainer make it easier to contribute, basically you just define the what's the basic/minimal development system (here ubuntu+python and requirements), and open source contributor could directly launch the repo on this predefine system.

The usual usage are:

  • Open VS-Code with devcontainer extensions installed, user click on open in devcontainer and the VS-Code launch in the devcontainer system with all requirements installed.
  • Open on cloud provider such as codespace/gitpod ... The cloud provider will directly read the devcontainer in order to repo with in the dev system.

So it's kind like your conda env, redondent with ./requirements but help a lot in the user/dev perspective.

It's up to you, I will at least keep it on my branch as it help me standardize my development system

@adamjstewart
Copy link
Collaborator

I've never heard of or used any of these things before, so I guess it's difficult for me to want to maintain these files. I've at least used pip/conda/spack before, so I don't mind supporting those installation methods. But any file we add to this git repo is something we're committing to maintain, and I'm trying to keep that burden minimal.

Like the docker PR, this feels very specific (what if someone wants to use RHEL instead of Ubuntu? or macOS or Windows? or Python 3.8?), and we don't want to maintain a file like this for every system and Python version. Maybe we could just add this file to .gitignore so you can keep it in your local copy without worrying about it getting sucked into PRs?

At least it doesn't duplicate the list of places I need to update dependencies. I would like to get rid of requirements/ but it's needed for CI. If I could, I would delete environment.yml too but I think @calebrob6 is using it 😄

So this isn't a no, but I'm not yet convinced.

@calebrob6
Copy link
Member

@julien-blanchon thanks for the contribution! I've never used Codespaces before, is the idea that if you open microsoft/torchgeo (or a fork of it) in a Codespace environment, then it will automatically run these files?

@adamjstewart I don't think this is a huge overhead (similar in scope to the pre-commit hook) and generally makes it easier for some people to edit. The only thing we would need to change is what is pip installed. I also don't think it is some slippery slope either -- if someone doesn't want to use it then they don't have and if someone wants it to be different then they can open a PR.

@adamjstewart
Copy link
Collaborator

similar in scope to the pre-commit hook

I want to get rid of this too 😆

@calebrob6
Copy link
Member

Why -- you don't have to maintain it? (put differently, these things don't get released / tested -- if they break they are going to break for technical people that are already trying to contribute and who will tell us about it)

Is there a like this nagging feeling that you get when something isn't under the comforting umbrella of pytest 🙂?

@adamjstewart
Copy link
Collaborator

you don't have to maintain it?

Someone has to maintain it. precommit becomes quickly out of date any time a style or mypy dep changes. I just had to upgrade the black version the other day.

Is there a like this nagging feeling that you get when something isn't under the comforting umbrella of pytest 🙂?

Yes 🙂

@calebrob6
Copy link
Member

Yeah but that's only because you have an insane memory for these things. If you forgot, then nothing bad would have happened and ashnair would have gotten to it (https://github.com/microsoft/torchgeo/commits/main/.pre-commit-config.yaml). If ashnair didn't get to it then someone else would have.

@calebrob6
Copy link
Member

(@julien-blanchon sorry for meta-discussion here, do you mind signing the CLA?)

@julien-blanchon
Copy link
Contributor Author

Yes sure,

@julien-blanchon please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@julien-blanchon
Copy link
Contributor Author

Here is a little example on the vscode desktop app. It should also work with Intellij, expect for the extensions part.

Screen.Recording.2023-02-04.at.02.03.47.mov

CPU and GPU configuration must be split, at least for now.

About codespace, here is the setup example:

Screenshot 2023-02-04 at 02 07 00

The image build could be quite long, expecially with codespace. So you can enable image prebuild in "settings/codespaces/prebuild_configurations/new". So any contributor will be able to launch the project with the specify configuration (same extensions, same black/mypy/... conf ...)

Copy link
Collaborator

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

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

Still not convinced that this is something we want to maintain (why stop at codespaces when there are dozens of other editors and environments with dotfiles we could add?) but figured I would comment on some of the issues I see.

.devcontainer/postCreateCommand.sh Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
.devcontainer/postCreateCommand.sh Outdated Show resolved Hide resolved
@adamjstewart
Copy link
Collaborator

I'm slowly warming up to the idea of adding this. Other repos (nbmake) also ship devcontainers, and it can make it easier to reproduce bugs.

@adamjstewart adamjstewart added this to the 0.5.0 milestone Feb 19, 2023
@calebrob6
Copy link
Member

@adamjstewart I'd like to merge this, I don't see any of the open issues as blockers and it makes it easier to for people to contribute to torchgeo

@adamjstewart
Copy link
Collaborator

I see all of the above as blockers, shouldn't be hard to investigate these.

@julien-blanchon
Copy link
Contributor Author

julien-blanchon commented Feb 24, 2023

Here is some improvement we can do in term of .devcontainer:

  • Remove gdal manual installation and let pip install it Not working
  • Add/Remove VSCode specific extensions for a unified experience: For community project like this one the best is to keep extensions as minimal as possible, and only ship extensions that are part of the formatting/linting process such as black, isort ...
  • Validate that the formatting/linting process work as espected. I've do my best to match your specific configuration for black, pylint, flake8 ... Still TODO
  • Add pip install -e . of torchgeo in postStartCommand, so the current torchgeo codebase will be install at the start of the container. Note that requirements library has already been install in the container.

@adamjstewart
Copy link
Collaborator

@julien-blanchon are you still working on this? Would love to get this merged someday so we can use codespaces for PR reviews.

@github-actions github-actions bot added the dependencies Packaging and dependencies label Mar 1, 2024
@github-actions github-actions bot removed the dependencies Packaging and dependencies label Mar 1, 2024
@julien-blanchon
Copy link
Contributor Author

@adamjstewart Could you have a look ! It's way simpler than before and work both on CPU and GPU

@julien-blanchon
Copy link
Contributor Author

Screenshot 2024-03-01 at 23 20 26

Look like almost all the test pass inside the devcontainer expect some dataset and transform ones. I'm not familiar enouth with torchgeo. Could you have a look into that before merging ?

Comment on lines +26 to +27
"ms-python.vscode-pylance",
"ms-python.pylint",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need these? Not sure if I want to enforce any style constraints that aren't already enforced in CI.

Copy link
Contributor Author

@julien-blanchon julien-blanchon Mar 2, 2024

Choose a reason for hiding this comment

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

That's extension, I would keep them espectially pylance. This give many IDE feedback to the user even before the CI. For example the current settings will display pylint error on the IDE side before any CI. Black will also auto format the code on file save with the same specification as the CI. This may put less work on the CI side and enforce best practice directly in the IDE

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I definitely want to keep black/mypy/isort/pydocstyle/flake8 because we also enforce that in CI. I'm specifically commenting on things like pylance and pylint which we don't use.

Copy link
Contributor Author

@julien-blanchon julien-blanchon Mar 2, 2024

Choose a reason for hiding this comment

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

You can remove pylint. I would keep pylance anyway because it's just visual, it doesn't enforce anything, but feel free to remove it if you'r sure you don't need it
Btw for torchgeo in general you can have a look to ruff that bundle everything in a single package.

Copy link
Collaborator

Choose a reason for hiding this comment

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

See #1908 (comment) for my thoughts on ruff. Not strongly opposed in principle, but let's discuss that in a separate issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does pylance flag anything that the other tools don't flag?

Copy link
Collaborator

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

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

Don't know much about this, but someday I'll learn how to use Codespaces and VS Code.

@adamjstewart adamjstewart added this to the 0.5.2 milestone Mar 2, 2024
@adamjstewart
Copy link
Collaborator

Can you tell me more about the failing tests? Do those tests fail for you when manually run in your local environment, or do they only fail in VS Code?

@julien-blanchon
Copy link
Contributor Author

julien-blanchon commented Mar 2, 2024

Can you tell me more about the failing tests? Do those tests fail for you when manually run in your local environment, or do they only fail in VS Code?

Seems to be due to the Python version. I think it's gone with the 3.12. I'm looking into that

@adamjstewart
Copy link
Collaborator

That's still odd, since we test Python 3.9–3.12 in CI and all pass.

@isaaccorley isaaccorley modified the milestones: 0.5.2, 0.5.3 Mar 2, 2024
@adamjstewart adamjstewart modified the milestones: 0.5.3, 0.6.0, 0.5.2 Mar 2, 2024
@adamjstewart
Copy link
Collaborator

Let's merge as is. We can always make improvements in future PRs. Want to squeeze this in before our next release.

@adamjstewart adamjstewart merged commit fe33e6c into microsoft:main Mar 2, 2024
24 checks passed
isaaccorley pushed a commit that referenced this pull request Mar 2, 2024
* ✨ Add devcontainer

* 🐛 Add postCreateCommand.sh

* Downgrade to Python 3.10

* Add gdal

* Separate CPU/GPU devcontainer.json

* Add cpu as default

* Rename default

* In order to enable vscode black auto format, color must be disable !

* Remove default root devcontainer

* Format and clean

* Switch to .[dataset ...]

* Add postStartCommand with pip install -e .

* Fix black

* Update

* Mise à jour des commandes postCreateCommand et postStartCommand dans devcontainer.json

* 🔥 Add devcontainer

* Update Python version and postStartCommand in devcontainer.json
@julien-blanchon
Copy link
Contributor Author

Let's merge as is. We can always make improvements in future PRs. Want to squeeze this in before our next release.

I'm going to investigate next week about the tests failed. I don't think it's blocking anyway

@julien-blanchon julien-blanchon deleted the devcontainer branch March 2, 2024 22:57
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

4 participants