Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 31, 2025

Tutorial scripts used development imports (from src.rcol...) that fail when the package is installed via pip with ModuleNotFoundError: No module named 'src'.

Changes

Import fixes

  • Changed tutorial_existing_instruments.py imports from src.rcol to rcol namespace
  • Verified tutorial_custom_instruments.py already uses correct imports

Documentation improvements

  • Added docstring headers with prerequisites and usage instructions to both tutorials
  • Added "Running Tutorial Scripts" section to README with pip installation steps
  • Structured tutorial code with section markers for clarity

Error handling

  • Replaced bare Exception catches with specific RedcapError
  • Added empty list check before pd.concat() in RTG instrument collection
  • Standardized RC_API_KEY environment variable usage

Example

Before:

from src.rcol.instruments import fal, ehi, bdi_ii
import src.rcol.rtg as rtg

After:

from rcol.instruments import fal, ehi, bdi_ii
import rcol.rtg as rtg

Users can now run tutorials directly after pip install rcol.

Original prompt

This section details on the original issue you should resolve

<issue_title>error when using tutorial for existing instruments</issue_title>
<issue_description>https://github.com/JuliusWelzel/rcol/blob/3937810f31b0fc6fa571115033e5e6fde876a11d/tutorial_existing_instruments.py#L5C6-L5C9
When using the tutorial for regular application (not development) this code throws an error.

ModuleNotFoundError: No module named 'src'
</issue_description>

<agent_instructions>fix this and put a strong emphasis on clean documentaiton</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 31, 2025 14:00
- Changed tutorial_existing_instruments.py imports from 'src.rcol' to 'rcol' for proper package usage
- Added comprehensive documentation headers to both tutorial files
- Added error handling and helpful error messages
- Updated README with "Running Tutorial Scripts" section
- Standardized RC_API_KEY usage across tutorials
- Added structured section markers for better code organization

Co-authored-by: JuliusWelzel <52565341+JuliusWelzel@users.noreply.github.com>
- Use specific RedcapError exception instead of bare Exception
- Add check for empty rtg_dfs list before concatenation
- Add graceful handling when no RTG instruments are found

Co-authored-by: JuliusWelzel <52565341+JuliusWelzel@users.noreply.github.com>
@JuliusWelzel JuliusWelzel marked this pull request as ready for review December 31, 2025 14:05
Copilot AI changed the title [WIP] Fix error in tutorial for existing instruments Fix tutorial imports for installed package usage Dec 31, 2025
Copilot AI requested a review from JuliusWelzel December 31, 2025 14:06
@JuliusWelzel JuliusWelzel merged commit f9cb4c8 into main Dec 31, 2025
18 checks passed
@JuliusWelzel JuliusWelzel deleted the copilot/fix-module-not-found-error branch December 31, 2025 14:06
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.

error when using tutorial for existing instruments

2 participants