diff --git a/requirements.txt b/requirements.txt index bb0a557880..5c58492dd2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,4 @@ PyPubSub >=4.0.3, <5 addict>=2.2.1, <2.5 pytz>=2012 enlighten>=1.5.2, <2 -typing-extensions +typing-extensions>=4.6.2, <5 diff --git a/src/toil/cwl/__init__.py b/src/toil/cwl/__init__.py index bf43d3142d..390d2fda6a 100644 --- a/src/toil/cwl/__init__.py +++ b/src/toil/cwl/__init__.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import logging +import sys from functools import lru_cache from pkg_resources import DistributionNotFound, get_distribution @@ -28,31 +28,30 @@ class InvalidVersion(Exception): # type: ignore from toil.version import cwltool_version -logger = logging.getLogger(__name__) - @lru_cache(maxsize=None) def check_cwltool_version() -> None: """ - Check if the installed cwltool version matches Toil's expected version. A - warning is printed if the versions differ. + Check if the installed cwltool version matches Toil's expected version. + + A warning is printed to standard error if the versions differ. We do not + assume that logging is set up already. Safe to call repeatedly; only one + warning will be printed. """ try: installed_version = get_distribution("cwltool").version if installed_version != cwltool_version: - logger.warning( - f"You are using cwltool version {installed_version}, which might not be compatible with " - f"version {cwltool_version} used by Toil. You should consider running 'pip install cwltool==" - f"{cwltool_version}' to match Toil's cwltool version." + sys.stderr.write( + f"WARNING: You are using cwltool version {installed_version}, which is " + f"not the version Toil is tested against. To install the correct cwltool " + f"for Toil, do:\n\n\tpip install cwltool=={cwltool_version}\n\n" ) except DistributionNotFound: - logger.debug("cwltool is not installed.") + # cwltool is not installed + pass except InvalidVersion as e: - logger.warning( - f"Could not determine the installed version of cwltool because a package " - f"with an unacceptable version is installed: {e}" + sys.stderr.write( + f"WARNING: Could not determine the installed version of cwltool because a package " + f"with an unacceptable version is installed: {e}\n" ) - - -check_cwltool_version() diff --git a/src/toil/cwl/cwltoil.py b/src/toil/cwl/cwltoil.py index b58361ce9d..b3015ba1cb 100644 --- a/src/toil/cwl/cwltoil.py +++ b/src/toil/cwl/cwltoil.py @@ -104,6 +104,8 @@ from toil.batchSystems.registry import DEFAULT_BATCH_SYSTEM from toil.common import Config, Toil, addOptions +from toil.cwl import check_cwltool_version +check_cwltool_version() from toil.cwl.utils import ( CWL_UNSUPPORTED_REQUIREMENT_EXCEPTION, CWL_UNSUPPORTED_REQUIREMENT_EXIT_CODE, diff --git a/src/toil/worker.py b/src/toil/worker.py index a0a7f5b14b..3d191385cd 100644 --- a/src/toil/worker.py +++ b/src/toil/worker.py @@ -250,8 +250,8 @@ def workerScript(jobStore: AbstractJobStore, config: Config, jobName: str, jobSt if redirectOutputToLogFile: # Announce that we are redirecting logging, and where it will now go. - # This is important if we are trying to manually trace a faulty worker invocation. - logger.info("Redirecting logging to %s", tempWorkerLogPath) + # This is only important if we are trying to manually trace a faulty worker invocation. + logger.debug("Redirecting logging to %s", tempWorkerLogPath) sys.stdout.flush() sys.stderr.flush()