From da6321c504c58029e4d8ae62cfef703d09bb586f Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Fri, 18 Oct 2024 10:58:57 +0200 Subject: [PATCH] (v2.1.1.9102) fix sir --- .github/prehooks/pre-commit | 4 +++- .github/workflows/publish-to-pypi.yml | 6 +++--- DESCRIPTION | 4 ++-- NEWS.md | 2 +- R/sir.R | 12 ++++++------ ...orRGPT.sh => _generate_GPT_knowledge_input.sh} | 15 ++++++++------- 6 files changed, 23 insertions(+), 20 deletions(-) rename data-raw/{AMRforRGPT.sh => _generate_GPT_knowledge_input.sh} (75%) diff --git a/.github/prehooks/pre-commit b/.github/prehooks/pre-commit index 34bace85..cd3dff0f 100755 --- a/.github/prehooks/pre-commit +++ b/.github/prehooks/pre-commit @@ -49,7 +49,6 @@ if command -v Rscript > /dev/null; then if [ "$(Rscript -e 'cat(all(c('"'pkgload'"', '"'devtools'"', '"'dplyr'"') %in% rownames(installed.packages())))')" = "TRUE" ]; then Rscript -e "source('data-raw/_pre_commit_checks.R')" currentpkg=$(Rscript -e "cat(pkgload::pkg_name())") - bash data-raw/AMRforRGPT.sh echo "- Adding changed files in ./data-raw and ./man to this commit" git add data-raw/* git add man/* @@ -112,4 +111,7 @@ echo "" # Save the version number for use in the commit-msg hook echo "${currentversion}" > .git/commit_version.tmp +# Generate GPT knowledge info for our Assistant (https://chatgpt.com/g/g-M4UNLwFi5-amr-for-r-assistant) +bash data-raw/_generate_GPT_knowledge_input.sh "${currentversion}" + exit 0 diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 08557ff1..5469850e 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -59,9 +59,9 @@ jobs: bash _generate_python_wrapper.sh - name: Publish to PyPI - # env: - # TWINE_USERNAME: "__token__" - # TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + env: + TWINE_USERNAME: "__token__" + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: | cd data-raw/python_wrapper/AMR python -m twine upload dist/* diff --git a/DESCRIPTION b/DESCRIPTION index 340c916b..4bfcf4a7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 2.1.1.9100 -Date: 2024-10-17 +Version: 2.1.1.9102 +Date: 2024-10-18 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by diff --git a/NEWS.md b/NEWS.md index 874633bd..e14b85f3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9100 +# AMR 2.1.1.9102 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)* diff --git a/R/sir.R b/R/sir.R index 45add462..6c4060eb 100755 --- a/R/sir.R +++ b/R/sir.R @@ -1739,12 +1739,12 @@ summary.sir <- function(object, ...) { c.sir <- function(...) { lst <- list(...) - guideline <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$guideline %||% NA_character_) - mo <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$mo %||% NA_character_) - ab <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ab %||% NA_character_) - method <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$method %||% NA_character_) - ref_tbl <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ref_tbl %||% NA_character_) - ref_breakpoints <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ref_breakpoints %||% NA_character_) + guideline <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$guideline %or% NA_character_) + mo <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$mo %or% NA_character_) + ab <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ab %or% NA_character_) + method <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$method %or% NA_character_) + ref_tbl <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ref_tbl %or% NA_character_) + ref_breakpoints <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ref_breakpoints %or% NA_character_) out <- as.sir(unlist(lapply(list(...), as.character))) diff --git a/data-raw/AMRforRGPT.sh b/data-raw/_generate_GPT_knowledge_input.sh similarity index 75% rename from data-raw/AMRforRGPT.sh rename to data-raw/_generate_GPT_knowledge_input.sh index 99bca848..5aaa384e 100644 --- a/data-raw/AMRforRGPT.sh +++ b/data-raw/_generate_GPT_knowledge_input.sh @@ -7,10 +7,11 @@ if [ "$(basename "$PWD")" != "AMR" ]; then fi # Define the output file, located in ./data-raw -output_file="data-raw/gpt_training_text.txt" +version="$1" +output_file="data-raw/gpt_training_text_v${version}.txt" # Clear the output file if it exists -echo "This files contains all context you must know about the AMR package for R."> "$output_file" +echo "This files contains all context you must know about the AMR package for R." > "$output_file" echo -e "\n\n\n\n" >> "$output_file" # Function to remove header block (delimited by # ======) @@ -20,7 +21,7 @@ remove_header() { # Process all .R files in the 'R' folder for file in R/*.R; do - echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file" + echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE $file" >> "$output_file" echo -e "\n\n" >> "$output_file" remove_header "$file" >> "$output_file" echo -e "\n\n" >> "$output_file" @@ -28,7 +29,7 @@ done # Process all .Rmd files in the 'vignettes' folder for file in vignettes/*.Rmd; do - echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file" + echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE $file" >> "$output_file" echo -e "\n\n" >> "$output_file" remove_header "$file" >> "$output_file" echo -e "\n\n" >> "$output_file" @@ -37,7 +38,7 @@ done # Process important metadata files (DESCRIPTION, NAMESPACE, index.md) for file in DESCRIPTION NAMESPACE index.md; do if [[ -f $file ]]; then - echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file" + echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE $file" >> "$output_file" echo -e "\n\n" >> "$output_file" cat "$file" >> "$output_file" echo -e "\n\n" >> "$output_file" @@ -46,7 +47,7 @@ done # Process test files (if available) in the 'tests' folder for file in tests/*.R; do - echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file" + echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE $file" >> "$output_file" echo -e "\n\n" >> "$output_file" remove_header "$file" >> "$output_file" echo -e "\n\n" >> "$output_file" @@ -54,7 +55,7 @@ done # Process all .Rd files from the 'man' folder for file in man/*.Rd; do - echo "THE NEXT PART CONTAINS CONTENTS FROM FILE $file" >> "$output_file" + echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE $file" >> "$output_file" echo -e "\n\n" >> "$output_file" remove_header "$file" >> "$output_file" echo -e "\n\n" >> "$output_file"