From 748fdd91308be5fe750c2e5b3456b82bdb457eaf Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Thu, 21 Nov 2024 13:34:27 +1100 Subject: [PATCH 1/5] fix test pypi location --- episodes/04-publishing.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/04-publishing.Rmd b/episodes/04-publishing.Rmd index c775e415..39f0d0af 100644 --- a/episodes/04-publishing.Rmd +++ b/episodes/04-publishing.Rmd @@ -747,7 +747,7 @@ We can test the distribution of our package by uploading to TestPyPI. First we will need to create a "token" on test-pypi to use as a temporary password. ```bash -$ hatch publish --repo testpypi --user __token__ --auth +$ hatch publish --repo https://test.pypi.org/legacy/ --user __token__ --auth pypi-token-here ``` To avoid entering you token on the cmd line you can provide details as env variables From d3174da102894a867d831672789a8d78b6805d51 Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Thu, 21 Nov 2024 13:34:27 +1100 Subject: [PATCH 2/5] fix test pypi location --- README.md | 9 +++++++++ episodes/04-publishing.Rmd | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2db2b3b2..4aa2dd50 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,17 @@ A lesson on creating and publishing packages in Python, implemented using the The website can be built locally using: +Install R deps: +```R +> install.packages(c("sandpaper", "varnish", "pegboard"), + repos = c("https://carpentries.r-universe.dev/", getOption("repos"))) +``` + +Build and serve website: ```bash $ Rscript build_script.R ``` Please consult the Carpentries Workbench docs for info on setting up your R environment. + +For `vscode`, install the `R Extension for Visual Studio Code` plugin and install the `languageserver` to get syntax highlighting in R Markdown documents. \ No newline at end of file diff --git a/episodes/04-publishing.Rmd b/episodes/04-publishing.Rmd index c775e415..39f0d0af 100644 --- a/episodes/04-publishing.Rmd +++ b/episodes/04-publishing.Rmd @@ -747,7 +747,7 @@ We can test the distribution of our package by uploading to TestPyPI. First we will need to create a "token" on test-pypi to use as a temporary password. ```bash -$ hatch publish --repo testpypi --user __token__ --auth +$ hatch publish --repo https://test.pypi.org/legacy/ --user __token__ --auth pypi-token-here ``` To avoid entering you token on the cmd line you can provide details as env variables From 4b412af69d618fc184cc066afbb968033eb60743 Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Thu, 21 Nov 2024 14:17:52 +1100 Subject: [PATCH 3/5] template notes --- learners/setup.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/learners/setup.md b/learners/setup.md index 0f85db1b..74f33bd3 100644 --- a/learners/setup.md +++ b/learners/setup.md @@ -117,6 +117,15 @@ Setup your test-pypi account: ## Create project repo +TODO: Create github template with init script + license + .gitignore + Create a new repo in your github account called `learn-hatch` and clone it to your local machine. -Tutor to discuss `.gitignore` and licences. \ No newline at end of file +Tutor to discuss `.gitignore` and licences. + + +## Create Conda env + +TODO: create new conda env.yml to include in template repo + +- inc biopython, seaborn \ No newline at end of file From 1b7582f53aa8757502907c85a16e9edcede22ecb Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Thu, 21 Nov 2024 14:18:07 +1100 Subject: [PATCH 4/5] add notes --- episodes/01-scripts-and-modules.Rmd | 34 ++++------------------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/episodes/01-scripts-and-modules.Rmd b/episodes/01-scripts-and-modules.Rmd index fe77de25..b44aa609 100644 --- a/episodes/01-scripts-and-modules.Rmd +++ b/episodes/01-scripts-and-modules.Rmd @@ -22,6 +22,8 @@ exercises: 2 ## Python as a Scripting Language +TODO: Cull text + Python is frequently used as a _scripting language_ by scientists and engineers due to its expressiveness, simplicity, and its rich ecosystem of third-party libraries. There isn't a hard line between a scripting language and a non-scripting language, but some @@ -648,37 +650,9 @@ if __name__ == "__main__": ``` An issue with our example is that it still requires the user to manually edit the file if they wish to change the input or outputs. This problem can be solved by instead -taking arguments from the command line. A simple interface can be created using -`sys.argv`, which is a list of command line arguments in the form of strings: - -```python -# file: SIR_model.py -import sys - -def main(): - # Note: sys.argv[0] is the name of our program! - pop_size = int(sys.argv[1]) - beta = float(sys.argv[2]) - gamma = float(sys.argv[3]) - days = int(sys.argv[4]) - I_0 = int(sys.argv[5]) - output = sys.argv[6] - - S, I, R = SIR_model( - pop_size=pop_size, - beta=beta, - gamma=gamma, - days=days, - I_0=I_0, - ) - plot_SIR_model(S, I, R, save_to=output) - -if __name__ == "__main__": - main() -``` +taking arguments from the command line. -However, this requires the user to provide every argument in order, and doesn't allow -default arguments. We can achieve a better interface using the built-in `argparse` +We can achieve a better interface using the built-in `argparse` library. The comments in the code below explain how this works: ```python From 23c7734c6153bafe3698346d6cf7b9d68f16b84c Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Thu, 21 Nov 2024 14:18:33 +1100 Subject: [PATCH 5/5] fix lesson 4 link --- episodes/03-building-and-installing.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/03-building-and-installing.Rmd b/episodes/03-building-and-installing.Rmd index a42d7d4a..f0b5fb3e 100644 --- a/episodes/03-building-and-installing.Rmd +++ b/episodes/03-building-and-installing.Rmd @@ -575,7 +575,7 @@ This indicates that `pip` should install any version of `numpy` greater than 1.2 that any version of `pyyaml` will do. If our installed `numpy` version is less than 1.20, or if it isn't installed at all, `pip` will upgrade to the latest version that's compatible with the rest of our installed packages and our Python version. We'll cover -software versioning in more detail in the [lesson on publishing](05-publishing.Rmd), but +software versioning in more detail in the [lesson on publishing](04-publishing.Rmd), but now we'll simply cover some ways to specify which software versions we need: ```toml