Closed UTexas80 closed 7 months ago
Hello @KentonWhite
My changes for the ProjectTemplate "Interleaved Python and R Code Execution in RStudio" are ready for your review.
If you have any questions, comments, or concerns please let me know.
Thank you for your time and consideration.
Regards,
Glen @UTexas80
Hello @KentonWhite
My changes for the ProjectTemplate "Interleaved Python and R Code Execution in RStudio" are ready for your review.
If you have any questions, comments, or concerns please let me know.
Thank you for your time and consideration.
Regards,
Glen @UTexas80
Types of change
Pull request checklist
man
Proposed changes
Interleaved Python and R Code Execution with Reticulate
Purpose: This test case verifies the ability of RStudio to seamlessly execute Python code interspersed with R code in a sequential order. The test utilizes the
reticulate
package to facilitate communication between R and Python environments.Scope:
reticulate
.Test Design:
1. Test Environment:
testthat
package installedreticulate
package installed2. Test Data:
3. Test Steps:
01-test_data.py
: Importspandas
andos
, creates a dataFramedata
, writes it to a CSV file (test_data_py.csv
) and performs a calculation (e.g., sum of a column) and prints the result.02-test_data.py
: Importspandas
,os
andsys
, reads/writes the CSV filetest_data_py.csv
) created in01-test_data.py
, creates a dataframepy_data
, defines a variablesubdirectory
, checks if thesubdirectory
variable exists in the python environment, passes the result to a variabledata
, prints whethery
orn
, writes a dynamically named dataframe eithery.csv
orn.csv
to themunge
subdirectoryreticulate
'ssource
function to sequentially load the Python scripts from the R Project Template package.except_false
andfile.exists
from thetestthat
package.except_false
from thetestthat
package.01-test_data.py
) to test capturing of the Python calculation result.01-test_data.R
) to test capturing of the R result tibble.02-test_data.py
) to test capturing of the Python environment result.02-test_data.R
) to test capturing of the R result tibble.4. Expected Results:
01-test_data.py
) should capture the expected result from the Python calculation and theexpect_true
,file.exists
assertion should pass.02-test_data.py
) should capture the expected result from the Python environment and theexpect_true
,file.exists
assertion should pass.01-test_data.R
) should capture the expected result from the R calculation and theexpect_true
,file.exists
assertion should pass.02-test_data.R
) should capture the expected result from the R environment and theexpect_true
,file.exists
assertion should pass.test_data_py.csv
,write_test_data_py.csv
andy.csv
) created by the Python script should exist and theexpect_true
,file.exists
assertion should pass.n.csv
) should not be created by the Python script and theexpect_false
,file.exists
assertion should pass.data
) created in the (01-test_data.py
) script should not be written to the R Environment and theexpect_false
, assertion should pass.5. Pass/Fail Criteria:
Additional Considerations:
Conclusion: This test case demonstrates the basic functionality of running Python code interspersed with R code using
reticulate
. By successfully passing this test, we gain confidence in RStudio's ability to integrate Python code within the R environment, allowing for flexible data analysis workflows that leverage the strengths of both languages.@KentonWhite