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

Improve logging in project deletes #171

Merged
merged 12 commits into from
Dec 6, 2024

Conversation

saipavan10-git
Copy link
Contributor

@saipavan10-git saipavan10-git commented Dec 2, 2024

This pull request includes significant changes to the delete_project function and its associated tests. The changes enhance logging, and update the test cases to reflect the new logging structure. Addresses #169

I tested the new delete function and now the project delete is visible on REDCap UI.

image

Enhancements to delete_project function:

  • Enhanced logging by adding detailed log parameters such as ts, user, ip, page, event, object_type, sql_log, pk, event_id, data_values, description, legacy, and change_reason.

Copy link
Contributor

@pbchase pbchase left a comment

Choose a reason for hiding this comment

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

See comments


# Define logging parameters
ts <- format(Sys.time(), "%Y%m%d%H%M%S") # Time stamp
user <- "admin" # Placeholder for user
Copy link
Contributor

Choose a reason for hiding this comment

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

Test this with an invalid username to see how REDCap's UI will behave.

Then, revise the code to default it first to, the value in sys.getenv("API_USER"), then--if invalid usernames are allowed--the script name.

# Define logging parameters
ts <- format(Sys.time(), "%Y%m%d%H%M%S") # Time stamp
user <- "admin" # Placeholder for user
ip <- "192.168.65.1" # Placeholder for IP address
Copy link
Contributor

Choose a reason for hiding this comment

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

Use getip::getip("local") to get the local IP address. Make getip a required package for redcapcustodian.

use getip package to log the ip address
Add getip package to requirements
@pbchase
Copy link
Contributor

pbchase commented Dec 5, 2024

@saipavan10-git, note that the checks are failing. If you drill in on that error you will see the error is pretty obvious: redcapcustodian now needs getip and the container used by the github action does not have that. I've fixed these before, but I should hand this one to you. I'll show you path, so you can fix it.

Could you document this procedure in addition to fixing it? The procedure doesn't seem clear unless you've already set up GitHub actions to perform automated testing. Any thoughts on where to put this procedure? Could we add a vignette for developers?

You can see the configuration for the action that failed at run-tests.yaml. It uses an image at ghcr.io/ctsit/rstudio-ci. The Dockerfile that defines that is at Dockerfile. Historically, we have added required packages in this Dockerfile. That should work quickly and easily, but I think you can install packages in run-tests.yaml that might be a better way to make the package self-documenting, but that might also make tests slower to run.

@saipavan10-git
Copy link
Contributor Author

I updated this dockerfile thinking this will fix the issue.

Adding a guide vignette for developers is a great idea. I can create one to document the fix for this issue. If we add new dependencies more frequently, we could add a step to setup dependencies in run-tests.yaml like in pkgdown.yaml. This will reduce the need to update the rstudio-Dockerfile. Also, setup r dependencies has an option to cache the packages that might help with the speed of the gh action.

@pbchase
Copy link
Contributor

pbchase commented Dec 5, 2024

I updated this dockerfile thinking this will fix the issue.

That's necessary, but not sufficient to make CI-tests work

Adding a guide vignette for developers is a great idea. I can create one to document the fix for this issue. If we add new dependencies more frequently, we could add a step to setup dependencies in run-tests.yaml like in pkgdown.yaml. This will reduce the need to update the rstudio-Dockerfile.

Right! I knew we had done this before, but I couldn't locate it.

Also, setup r dependencies has an option to cache the packages that might help with the speed of the gh action.

That minimizes the downside of the more local management of dependencies. I like it :-)

@pbchase pbchase merged commit 1672327 into ctsit:develop Dec 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants