diff --git a/DESCRIPTION b/DESCRIPTION index 878ccadb5..2fc55a1bd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9221 +Version: 2.1.1.9222 Date: 2025-03-20 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 0ce266ae9..49a1507e8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9221 +# AMR 2.1.1.9222 *(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/data-raw/_generate_python_wrapper.sh b/data-raw/_generate_python_wrapper.sh index 71b3ce764..c3625c97c 100644 --- a/data-raw/_generate_python_wrapper.sh +++ b/data-raw/_generate_python_wrapper.sh @@ -44,52 +44,52 @@ description_file="../DESCRIPTION" cat < "$datasets_file" import os import sys -from rpy2 import robjects -from rpy2.robjects import pandas2ri -from rpy2.robjects.packages import importr, isinstalled import pandas as pd import importlib.metadata as metadata # Get the path to the virtual environment venv_path = sys.prefix - -# Define R library path within the venv r_lib_path = os.path.join(venv_path, "R_libs") -# Ensure the R library path exists os.makedirs(r_lib_path, exist_ok=True) +# Set environment variable before importing rpy2 +os.environ['R_LIBS_SITE'] = r_lib_path + +from rpy2 import robjects +from rpy2.robjects import pandas2ri +from rpy2.robjects.packages import importr, isinstalled + # Import base and utils base = importr('base') utils = importr('utils') -base.options(warn = -1) +base.options(warn=-1) -# Override R library paths globally for the session -robjects.r(f'.Library.site <- "{r_lib_path}"') # Replace site-specific library -base._libPaths(r_lib_path) # Override .libPaths() as well - -# Get the effective library path -r_amr_lib_path = base._libPaths()[0] +# Ensure library paths explicitly +base._libPaths(r_lib_path) # Check if the AMR package is installed in R -if not isinstalled('AMR', lib_loc=r_amr_lib_path): - print(f"AMR: Installing latest AMR R package to {r_amr_lib_path}...", flush=True) +if not isinstalled('AMR', lib_loc=r_lib_path): + print(f"AMR: Installing latest AMR R package to {r_lib_path}...", flush=True) utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) -# Python package version of AMR +# Retrieve Python AMR version try: python_amr_version = metadata.version('AMR') except metadata.PackageNotFoundError: python_amr_version = '' -# R package version of AMR -r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_amr_lib_path}"))') +# Retrieve R AMR version +r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))') r_amr_version = str(r_amr_version[0]) +print(python_amr_version) +print(r_amr_version) + # Compare R and Python package versions if r_amr_version != python_amr_version: try: - print(f"AMR: Updating AMR package in {r_amr_lib_path}...", flush=True) + print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True) utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) except Exception as e: print(f"AMR: Could not update: {e}", flush=True) diff --git a/data-raw/gpt_training_text_v2.1.1.9221.txt b/data-raw/gpt_training_text_v2.1.1.9222.txt similarity index 99% rename from data-raw/gpt_training_text_v2.1.1.9221.txt rename to data-raw/gpt_training_text_v2.1.1.9222.txt index 0412d31cc..58873026d 100644 --- a/data-raw/gpt_training_text_v2.1.1.9221.txt +++ b/data-raw/gpt_training_text_v2.1.1.9222.txt @@ -1,6 +1,6 @@ This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse. -First and foremost, you are trained on version 2.1.1.9221. Remember this whenever someone asks which AMR package version you’re at. +First and foremost, you are trained on version 2.1.1.9222. Remember this whenever someone asks which AMR package version you’re at. Below are the contents of the NAMESPACE file, the index.md file, and all the man/*.Rd files (documentation) in the package. Every file content is split using 100 hypens. ----------------------------------------------------------------------------------------------------