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

A methodology should be implemented to handle dependences for examples. #69

Open
Devin-Crawford opened this issue Mar 23, 2024 · 3 comments
Labels
enhancement New features or code improvements

Comments

@Devin-Crawford
Copy link
Collaborator

📝 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:

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:

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

@Devin-Crawford Devin-Crawford added the enhancement New features or code improvements label Mar 23, 2024
@Devin-Crawford Devin-Crawford mentioned this issue Mar 23, 2024
6 tasks
@SMoraisAnsys
Copy link
Collaborator

I'm not too favorable with this approach for multiple reasons. Some can be argued as we provide example ourselves and control everything but for others I have concerns:

  • version control can't be achieved with that approach and new version of a package could be incompatible with the code
  • executing subprocess calls can present security issues (arguable since we control the code of the examples)
  • portability might be an issue as every user might have a different python configuration (arguable)
  • separating preoccupations about up dependencies update and code execution

However, it might make sense to gather dependencies groups for specific folders / group of examples. We would have additional targets (like we have for [doc] or [tests]). @dcrawforAtAnsys What do you think ?

@Samuelopez-ansys
Copy link
Member

@SMoraisAnsys @dcrawforAtAnsys I like last idea, to have groups of dependencies for group of examples

@Devin-Crawford
Copy link
Collaborator Author

@Samuelopez-ansys , @SMoraisAnsys : This makes sense if it is feasible.

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

No branches or pull requests

3 participants