A methodology should be implemented to handle dependences for examples.
- Dominant language
- No language data
- Stars
- 44
- Forks
- 13
- Avg merge
- 5d 12h
- Merged PRs (30d)
- 6
Description
### 📝 Description of the feature
I suggest a method be implemented to check for and update dependencies for examples. Since the examples are very broad and general, it does not make sense to include all dependencies for all examples. Instead, one might create a list of packages (or dict with package name as the key and version string as the value) and pass that dict to a function that will update the local Python environment.
### 💡 Steps for implementing the feature
The example could then look like:
``` python
add_packages = ["plotly": ">=5.6.0", "matplotlib": "latest"]
update = check_packages(update=True, add_packages)
```
The code from the EMIT example could be used as a reference to create the ``check_packages()`` function:
```python
reqs = subprocess.check_output([sys.executable, "-m", "pip", "freeze"])
installed_packages = [r.decode().split("==")[0] for r in reqs.split()]
# Install required packages if they are not installed
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
# Install plotly (if needed) to display legend and
# scenario matrix results (internet connection needed)
required_packages = ["plotly"]
for package in required_packages:
if package not in installed_packages:
install(package)
```
### 🔗 Useful links and references
_No response_
Contributor guide
Research direction
Start by locating the EMIT example and reviewing its subprocess-based pip-freeze and installation logic. Determine where a shared dependency-checking method belongs and define completion around examples being able to request package names and versions, detect missing dependencies, and update the local Python environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100