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

🐞 Bug Bash wk 2🐞 Add: second lesson and images #120

Closed
wants to merge 19 commits into from

Conversation

lwasser
Copy link
Member

@lwasser lwasser commented Dec 5, 2023

This is the second PR associated with the tutorial lesson development. it is ready for review. in this lesson a beginners learns how to make code pip installable. 🐞

@lwasser lwasser changed the title Add: second lesson and images to pr Add: second lesson and images Dec 5, 2023
@lwasser lwasser marked this pull request as ready for review December 11, 2023 17:15
@lwasser lwasser changed the title Add: second lesson and images 🐞 Bug Bash wk 2🐞 Add: second lesson and images Dec 11, 2023
Copy link
Contributor

@kierisi kierisi left a comment

Choose a reason for hiding this comment

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

added my notes! I went through and provided comments as I went, rather than reading through a couple times and then giving feedback. so some of my comments are answered later in the tutorial, but I left the comments at the place in the tutorial where the question arose for me, and where it would be helpful to have some signposting.

images/tutorials/environment-package-install.png Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved

### Step 1: Set Up the Package Directory Structure

Create a new directory for your package. Choose a name for your package, preferably in lowercase and without spaces (e.g., "pyospackage_yourname").
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this seems basic, but beginners don't always know that a folder and directory are the same thing. it might be worth clarifying the first time directory is used, and then repeating throughout the tutorial.


Inside the package directory,

- Create a `src/` directory
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be beneficial to provide a quick Create a src/ directory by... and giving a 1-2 sentence bit of instruction on this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably want this to be a src directory and drop the slash.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok got it.

can you please test this in shell for me? it works in my zsh shell so far

# Create a project directory in shell and a src directory within
mkdir -R pyospackage/src/pyospackage
# Change directory into pyospackage project dir 
cd pyospackage 
# View the current file structure 
ls
# Create a pyproject.toml file in your project directory 
touch pyproject.toml
# Create an empty init file within your src/pyospackage directory 
touch src/pyospackage/__init__.py

Your final project directory structure should look like this:

pyospackage/  # This is your project directory
     └─ pyproject.toml
     └─ src/ # This is your package directory where your code lives
             └── pyospackage_yourname/
              	     ├── __init__.py

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've never used a mkdir with a -R option. I think you might have meant mkdir -p

Copy link
Member Author

Choose a reason for hiding this comment

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

🙈 and i think i just made up a flag didn't i? thank you for the catch!! you are right. i am not sure where i got R from TBH. recursive? 🤷‍♀️

tutorials/1-installable-code.md Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@willingc willingc left a comment

Choose a reason for hiding this comment

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

Overall, this is taking shape nicely.

tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Show resolved Hide resolved
have is to make that code pip installable. You will learn how to make
your code pip installable in this lesson.

<!--
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 remove the comment and create a checklist of questions in a github issue.

tutorials/1-installable-code.md Outdated Show resolved Hide resolved

* [If you need guidance creating a Python environment, review this lesson](extras/1-create-environment.md) which walks you through creating an environment using both `venv` and `conda`.
* If you aren't sure which environment manager to use and
you are a scientist, we suggest that you use `conda`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
you are a scientist, we suggest that you use `conda`.
you are a scientist, we suggest that you begin with `conda` because conda offers flexibility to extend to other programming languages, such as C, C++.

tutorials/1-installable-code.md Outdated Show resolved Hide resolved

Inside the package directory,

- Create a `src/` directory
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably want this to be a src directory and drop the slash.

tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@ucodery ucodery left a comment

Choose a reason for hiding this comment

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

This is a really great tutorial!

# Make your Python code pip installable

The first step in creating a Python package based on code that you
have is to make that code pip installable. You will learn how to make
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure that we need to have "pip installable" everywhere. True, it's the most common installer, and I'm good if we sometimes say pip-installable, or use pip for real examples. But "install(able)" seems to convey as much relevant information and won't cause confusion if/when we introduce other tools (like conda).
(edit) after going through the whole file I see it's not all pip-install and this point has already been raised. But I still find it odd that the h1 heading mentions pip.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok i have a question @ucodery is there a way to install this type of package with conda? it never occurred to me that one could conda install a package locally if it wasn't a "conda packaged package" if that makes sense.

i'm fine with backing off the language pip. as i suppose you could do a hatch install or pdm install or poetry install too!

but your comment made me wonder about the range of tools that could actually install a package beyond pip and whether conda was actually in the mix.

for now i'll leave this comment open and will reread the lesson with that lense given at a minimum hatch, poetry and pdm (and flit??) could all potentially install this package we are teaching them to create here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't use conda, so I don't know if it can do a local install. As for the other packaging tools, those that are package managers can install as you noted (so not flit). There is also the low-level installer tool as well as older, deprecated installers such as easy_install.

Copy link
Member Author

Choose a reason for hiding this comment

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

got it - thank you!

The reason why i've been careful about pip vs conda here is that a lot of scientists use conda (me included). And installing a conda version of python is so so easy - you can easily then create envts using various python versions with a single command, and it's friendlier if you are using tools that process spatial data.

so many will come from a conda background and need to understand how pip vs conda works. if we rely ONLY on python.org python and pip some scientists will have to relearn envt management. and it will get confusing i think.

either way i think this will be a bit of a thorn that we need to polish down in our lessons - which is why i thought about suggesting conda but having instructions for a non conda envt manager as well such as venv given it's native to python installs. then we can have a lesson (i have one started already) on venv vs conda installs.

Copy link
Member Author

Choose a reason for hiding this comment

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

leaving this open for now. as it might warrant more discussion in slack / here to get it right!

images/tutorials/code-to-script-diagram.png Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
tutorials/1-installable-code.md Outdated Show resolved Hide resolved
@lwasser lwasser force-pushed the bb-dec23-install-code branch from 7473f6b to af6c0ac Compare January 3, 2024 21:02
@lwasser
Copy link
Member Author

lwasser commented Jan 3, 2024

closing this via #120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants