{"id":9764,"library":"galaxy-util","title":"Galaxy Utilities","description":"The `galaxy-util` package provides common utility functions and helper classes used across the larger Galaxy bioinformatics platform. It is an integral part of the Galaxy ecosystem, supporting various functionalities within the main application. Currently at version 26.0.0, it follows the rapid release cadence of the main Galaxy project, often tied to its major releases. While available on PyPI, its primary use case is within the Galaxy project itself.","status":"active","version":"26.0.0","language":"en","source_language":"en","source_url":"https://github.com/galaxyproject/galaxy","tags":["galaxy","utilities","bioinformatics","internal-library"],"install":[{"cmd":"pip install galaxy-util","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required Python version for compatibility.","package":"python","optional":false}],"imports":[{"note":"The PyPI package `galaxy-util` exposes its modules under the `galaxy.util` namespace, not `galaxy_util`.","wrong":"from galaxy_util.path import safe_path","symbol":"safe_path","correct":"from galaxy.util.path import safe_path"},{"symbol":"parse_json_string","correct":"from galaxy.util.json import parse_json_string"},{"symbol":"sanitize_text","correct":"from galaxy.util.sanitize_text import sanitize_text"}],"quickstart":{"code":"from galaxy.util.path import safe_path\nfrom galaxy.util.sanitize_text import sanitize_text\n\n# Example 1: Safely resolve a path component\nunsafe_path_component = '../etc/passwd'\nsafe_component = safe_path(unsafe_path_component)\nprint(f\"Unsafe: {unsafe_path_component}, Safe: {safe_component}\")\n\n# Example 2: Sanitize text input\nraw_text = '<script>alert(\"XSS\")</script>Hello & World!'\nsanitized_text = sanitize_text(raw_text)\nprint(f\"Raw: {raw_text}\\nSanitized: {sanitized_text}\")\n","lang":"python","description":"This quickstart demonstrates basic usage of two common utility functions: `safe_path` for sanitizing path components and `sanitize_text` for removing potentially dangerous HTML/script tags from strings. These are representative of the type of general-purpose helpers found in `galaxy-util`."},"warnings":[{"fix":"Refer to the Galaxy project's official release notes and source code (`lib/galaxy/util` directory in the main Galaxy repository) for the specific version you are using to confirm API stability and correct usage.","message":"APIs within `galaxy.util` can change significantly between major Galaxy releases (e.g., v25 to v26). As an internal utility package, modules, functions, or their signatures might be refactored, moved, or removed without explicit deprecation warnings targeted at external users.","severity":"breaking","affected_versions":"All versions, especially major increments."},{"fix":"Consider if a more general-purpose Python library exists for your specific utility need before integrating `galaxy-util` into non-Galaxy applications. Be prepared for potential API instability if you do use it externally.","message":"The `galaxy-util` package is primarily designed for internal use within the Galaxy project. Its APIs are tightly coupled with the larger Galaxy application's internal structure and evolution, and may not always be suitable or stable for standalone, general-purpose use outside of the Galaxy ecosystem.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that your `galaxy-util` version is compatible with your `galaxy` core version. Ideally, manage dependencies through the main Galaxy project's recommended setup or requirements.txt.","message":"Version mismatches between `galaxy-util` and the main `galaxy` package (if you are developing for Galaxy) can lead to unexpected behavior, `AttributeError`s, or runtime failures, as they are developed and released in tandem.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed: `pip install galaxy-util`. If using a virtual environment, ensure it's activated.","cause":"The `galaxy-util` package has not been installed, or your Python environment's path does not include the installation location.","error":"ModuleNotFoundError: No module named 'galaxy.util'"},{"fix":"Check the `galaxy.util` source code in the Galaxy project's GitHub repository (`lib/galaxy/util` for your specific version) to find the current API or an alternative. Update your code to reflect the new API.","cause":"The specific utility function or class you are trying to import/use (`some_function_name`) was removed, renamed, or refactored in the version of `galaxy-util` you have installed. This is common due to its internal utility nature.","error":"AttributeError: module 'galaxy.util.path' has no attribute 'some_function_name'"},{"fix":"Consult the Galaxy project's official documentation or examine the source code for the exact `galaxy-util` version you are using to determine the correct import path or if the functionality has been replaced.","cause":"A class or function previously available in a submodule of `galaxy.util` has been moved to a different module, or it has been removed entirely during a refactoring.","error":"ImportError: cannot import name 'SomeSpecificClass' from 'galaxy.util.tool_shed'"}]}