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

Update Local Package Path to Editable Mode in Jupyter Notebook #20

Open
g4brielvs opened this issue Apr 3, 2024 · 2 comments
Open

Update Local Package Path to Editable Mode in Jupyter Notebook #20

g4brielvs opened this issue Apr 3, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@g4brielvs
Copy link
Member

g4brielvs commented Apr 3, 2024

In Jupyter notebooks, for example in this notebook, replace the import from a path with a Python package installed via pip for better maintainability and development.

Steps to Implement:

  1. Create a Python package red-sea-monitoring (already created).
  2. Install the Python package via pip.
  3. Replace the import from path with the Python package import in the code.

For example

In the repository directory, install the package in editable mode with dependencies:

pip install -e .

and, in the notebook,

from red_sea_monitoring.utils import *

When you install a package, it manages dependencies for you. This ensures that the required dependencies are correctly installed and compatible with the package you are installing. Installing a package makes your code more portable. You can share your code with others, and they can easily install the required packages using a package manager. For end-users or colleagues who are not familiar with the project, installing a package is simpler than manually managing paths.

The package can be installed/distributed in a standard way:

pip install git+https://github.com/datapartnership/red-sea-monitoring.git
>>> import red_sea_monitoring
>>> red_sea_monitoring.__version__
'0.1.dev56+gba2d2ff'
@andresfchamorro
Copy link
Collaborator

andresfchamorro commented Apr 10, 2024

Thanks, I will adjust the notebooks shortly. Can we delete src/red-sea-monitoring? I found it confusing to find two folders @g4brielvs

@g4brielvs
Copy link
Member Author

g4brielvs commented Apr 10, 2024

Thanks, I will adjust the notebooks shortly. Can we delete src/red-sea-monitoring? I found it confusing to find two folders @g4brielvs

@andresfchamorro Thanks! When rereading this issue, I realized my suggestion might not have come across as a suggestion. Apologies for that. In any case, I would still encourage packaging adequately, which will make the code more portable, reproducible and maintainable, but I am curious about your thoughts before any decisions :)

And absolutely. src-red-sea-monitoring is not valid and it was introduced by #23. We should move it and I'll open a PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants