-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from DHI/fix_warnings_of_compatibility_with_ot…
…her_packages Fix warnings of compatibility with other packages
- Loading branch information
Showing
6 changed files
with
63 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Provides useful warnings about conflicts related to usage alongside mikeio and mikeio1d.""" | ||
|
||
import sys | ||
import os | ||
|
||
MIKEIO1D_IMPORTED_BEFORE_MIKEPLUS = "mikeio1d" in sys.modules | ||
DISABLE_CONFLICT_CHECKS = ( | ||
os.getenv("MIKEPLUSPY_DISABLE_CONFLICT_CHECKS", "false").lower() == "true" | ||
) | ||
|
||
|
||
def check_conflicts(): | ||
"""Check for conflicts with mikeio and mikeio1d. | ||
This function checks if mikeio1d was imported before mikeplus. If so, it raises an error | ||
that mikeio1d must be imported after mikeplus. | ||
It also checks if mikeio is imported. If so, it raises an error that mikeio cannot currently | ||
be used in same process as mikeplus. | ||
""" | ||
|
||
if DISABLE_CONFLICT_CHECKS: | ||
return | ||
|
||
if MIKEIO1D_IMPORTED_BEFORE_MIKEPLUS: | ||
raise ImportError( | ||
"mikeio1d must be imported after mikeplus to avoid conflicts. See docs for more info." | ||
) | ||
|
||
if "mikeio" in sys.modules: | ||
raise ImportError( | ||
"""mikeio cannot currently be used in same process as mikeplus. | ||
Workarounds include splitting code into separate scripts or using | ||
Python's multiprocessing library to import mikeio and mikeplus in | ||
separate processes. See docs for more info.""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters