-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
DOCS: create how-to page on environments with hatch #1208
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! What do you think about leaving this page mostly untouched and instead create a new docs/how-to/environment/PAGE_NAME.md
? Context: #1123 (comment)
Examples:
@ofek i'm happy to help with tutorials and to migrate this to a tutorial/how to page.
i guess one thing i'm a bit worried about is you have a page dedicated to environments and then another tutorial page on environments. it could get confusing for a user to have to look at both pages but if things are clearly linked it could be ok and i'm happy to work on it either way once i understand the plan! |
|
ok great - give me a few days - i'll refactor this PR and turn it into a how-to with links from that environment page! |
Hey @ofek ,
I hope you find reason in my suggestions. |
hey @DahanDv 👋 are you thinking that we could create a meta issue perhaps with an outline of the pages the @ofek and the community could use. and then we could open issues as contributors to tackle items? That way ofek could guide contributors through what is needed and what he's like to see and we could more effectively contribute? i would find that useful as a new contributor. i just contributed to the envt page (which will become a how to once i work on this more) because i was trying to understand environments and noticed others had the same questions that i did. hatch provides a different model. it's actually really nice now that i understand how it works. it's just different from what i'm used to in Python. |
@lwasser Hey there! Regarding your suggestion about meta issue: |
Thank you both for the discussion, great stuff! I do like the idea of a meta issue. Additionally, I should add a contributing section to the docs that has a page for code, documentation, and releasing (for maintainers). I do plan on adhering to that documentation framework more and tutorials will be necessary. If you wouldn't mind creating a tutorial for version management as you mentioned that would be awesome! Could one of you perhaps please create the meta issue where we can enumerate the initial planned how-to pages? After I get a sense of what it looks like I can turn it into a GitHub project for tracking. |
Thank you @ofek !
Just to make sure my interpretation is correct:
yes I'd love to deliver this Python version management tutorial. Assign me on this once you have the tracking tool (meta issue/project) in place!
Great! |
> hatch shell | ||
``` | ||
|
||
todo: launch into a shell for the test envt? how? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ofek or anyone - i can't figure out how to launch into a shell for a specific environment such as test. i tried
hatch shell test
hatch run test:shell (doesn't make sense but tried it)
hatch -e test shell
how do i get a user into their test shell in case they want to do some work at the CLI in that envt?
thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one you mentioned works hatch -e test shell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does. @ofek i'm going to work on it a bit more tonight. i must have been tired last night hatch -e test shell
works.
hi 👋 @DahanDv @ofek sure - i can work on the meta issue this week. Essentially we can create a structure of content that will hit the basic user needs in terms of tutorials and how tos (i find these two types of content to be tricky sometimes to distinguish between :) ). And then from that issue (i'm sure we will have a lot of back and forth but i'll keep the first comment updated with the latest desired structure, we can create individual issue / tasks that can be assigned to specific people (or even can be flagged with help-wanted labels to direct users to what is needed. in the meantime - i could use a review of this current how-to if either of you have time! ✨ i didn't add anything on cleanup / pruning environments. and specifically i could not figure out how to "spawn" a shell for a specific environment. pyosPackage (☊ main) [✎ ×1 ] is 📦 v0.1.4 via 🐍 pyenv (pyospackage)
❯ hatch shell test
Already in environment: default
pyosPackage (☊ main) [✎ ×1 ] is 📦 v0.1.4 via 🐍 pyenv (pyospackage)
❯ exit
pyosPackage (☊ main) [✎ ×1 ] is 📦 v0.1.4 via 🐍 pyenv took 53s
❯ hatch shell test
source ".../path/hatch/env/virtual/pyospackage/twO2iQR3/pyospackage/bin/activate"
pyosPackage (☊ main) [✎ ×1 ] is 📦 v0.1.4 via 🐍 pyenv
➜ source ".../path/hatch/env/virtual/pyospac
kage/twO2iQR3/pyospackage/bin/activate"
pyosPackage (☊ main) [✎ ×1 ] is 📦 v0.1.4 via 🐍 pyenv (pyospackage)
➜ pytest
zsh: command not found: pytest many thanks! |
│ default │ virtual │ │ | ||
├─────────┼─────────┼──────────────┤ | ||
│ test │ virtual │ pytest │ | ||
└─────────┴─────────┴──────────────┘ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lwasser Are you running the latest version of Hatch?
I have another column in this table: "Scripts"
Did you remove it for simplicity?
From a diataxis POV, this can trigger anxiety for beginners trying to follow and observe unexplained delta from the how-to.
It's small but worth thinking of.
Consider this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am! 1.9.3.
so @DahanDv please note that the output of all of this depends on the pyproject.toml file that a user begins with.
If a user is migrating to hatch they may or may not have that full verbose pyproject.toml that you get with the default hatch init
. Further, if your config is setup in a way that excludes test matrices when you run hatch init then it also won't have those additional columns / matrix setup.
because in a how-to file, I dont think we can assume a specific user entry point/ I'd rather keep things simple. BUT perhaps it's worth adding a breakout to note your point above about how you may get different results depending upon how you begin to use hatch. In the tutorials we are creating for pyOpenSci we are leading the user through all of the steps and suggesting they won't start with the matrix envt / more complex pyproject.toml just to decrease cognitive load at the beginning. But we will introduce it later. I think for a tutorial exploring all of the ins and outs is a good idea but a how-to should be more concise just giving a user how to do x,y,z without assumptions.
my two cents :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added:
Note
The output may have more columns depending on your environment configuration.
Hatch will always use the `default` environment if an environment is not chosen explicitly when running a command. | ||
|
||
For instance, the command below builds your project in the default Hatch environment. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You made a super important point that hatch will go to default env unless told otherwise.
But I would rather use an example that "proves" this in a negative way. To get verbose feedback.
i.e., calling a script defined from another env or calling a pip list
from another env with different dependencies.
Since this is about making a point that is true to ALL usages of the env feature, I think this is a point to make in a tutorial.
Emphasizing that how-to is for specific purposes to accomplish - like you did with the examples of isolated test env.
(I know I'm being pedantic ignore me if it's too much - it's Ofek's call anyways)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi there @DahanDv my understand is this is a how-to not a tutorial. as such i think we just want to show people here how to do things rather than a tutorial that might explore various things that work and don't work. i'm definitely open to feedback but based on what @ofek linked to i how to's are more to the point - how to do this thing well.
i'm of course open to discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved to this to a brand-new tutorial section since yes I think how-to documents should be more targeted.
I have the same issue and came upon this PR, so I think this is the right place to ask, but is this unwanted behavior? Specifically in the docs it says |
Hey @jhossbach 👋 try this: ➜ hatch -e test shell
source "/Users/leahawasser/Library/Application Support/hatch/env/virtual/pyospackage/Fw213C8y/test/bin/activate"
pyosPackage (☊ main) [✎ ×1 ?] is 📦 v0.1.10 via 🐍 pyenv
➜ source "/Users/leahawasser/Library/Application Support/
hatch/env/virtual/pyospackage/Fw213C8y/test/bin/activate"
pyosPackage (☊ main) [✎ ×1 ?] is 📦 v0.1.10 via 🐍 pyenv (test)
➜ pytest
================== test session starts ==================
platform darwin -- Python 3.12.1, pytest-8.0.0, pluggy-1.4.0
rootdir: /my/path/GitHub/pyos/pyospackage
plugins: cov-4.1.0
collected 0 items
================= no tests ran in 0.01s =================
pyosPackage (☊ main) [✎ ×1 ?] is 📦 v0.1.10 via 🐍 pyenv (test)
❯ pip list
Package Version Editable project location
----------- ------- ----------------------------------------------------
coverage 7.4.1
iniconfig 2.0.0
packaging 23.2
pip 23.3.1
pluggy 1.4.0
pyospackage 0.1.10 /path/GitHub/pyos/pyospackage
pytest 8.0.0
pytest-cov 4.1.0
I was doing the same thing as you. so it's hatch -e envt-name shell i've updated this how-to with that information and things are working well now! :) soon to be added to the docs! |
ok @ofek can you (when you have time) please review this again. my apologies for the delay - life got busy. but i didn't forget about this. :) i can also work on an issue where we can iterate with @DahanDv and whomever else wishes to work on this! i'll also - as i work on things try to find issues related to them to pull in the people opening issues into reviewing the how-to and tutorial items that we add!! And updated contributing info / a development guide with release info would be wonderful. altho i did also find your existing contributing info to be great. i'm really enjoying hatch now that i better understand how things work. |
I'll fix this up after dinner today and merge! |
tests were 🔴 so i just rebased. but it shouldn't have anything to do with this PR as it's only documentation changes. |
yay - ✅ !! all tests passing now. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your effort here and sorry for the wait! I converted this into a tutorial (first one!) and fixed a few typos and also added cross-links to other pages.
If you feel more should be added, feel free to open up another PR 🙂
Co-authored-by: Ofek Lev <[email protected]> 24e5454
This pr attempts to address:
@ofek i missed the configuration section when initially reading this so i tried to add links to that section as well. I"m really happy to edit / fix etc if this isn't inline with what you want for the docs. I left a few questions using html comments in the text which will help me clarify a bit more. i'll also post this pr in the discussions in case that's helpful for others searching
Finally - this is my first time contributing here and my first time dealing with mkdocs so feel free to let me know if i did things incorrectly or if there is a way to make things easier for you to review.