### Serve Documentation Preview Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Start a local web server to preview the documentation. This command is used after installing dependencies and setting up the documentation build environment. ```bash mkdocs serve ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Install the necessary dependencies to preview the documentation locally. This command installs the package in editable mode with example and documentation extras. ```bash uv pip install -e .[examples,docs] ``` -------------------------------- ### Install openml with test dependencies and pre-commit Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Install the openml package with its test dependencies and configure pre-commit hooks from the repository folder. This command should be run after activating the virtual environment. ```bash uv pip install -e .[test] pre-commit install ``` -------------------------------- ### Install uv package manager Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Install the `uv` package manager using pip. This is recommended for a smooth development experience. ```bash pip install uv ``` -------------------------------- ### Install and Run Pre-commit Hooks Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Set up pre-commit hooks to enforce coding standards and run them on all files in the repository. ```bash pre-commit install pre-commit run --all-files ``` -------------------------------- ### Launch API v1 Docker Services Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Initialize and start the Docker container stack for the API v1 backend. ```bash docker compose --profile all up -d ``` -------------------------------- ### Install openml-python Dependencies Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Install the openml-python package in editable mode, including development and documentation dependencies. ```bash python -m pip install -e ".[dev,docs]" ``` -------------------------------- ### Create and activate virtual environment with uv Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Create a virtual environment named 'openml-python' using `uv` with Python 3.8, activate it, and then install `uv` within the virtual environment. ```bash uv venv --seed --python 3.8 ~/.venvs/openml-python source ~/.venvs/openml-python/bin/activate pip install uv # Install uv within the virtual environment ``` -------------------------------- ### Install OpenML-Python Source: https://github.com/openml/openml-python/blob/main/README.md Installs the OpenML-Python library using pip. This command is suitable for Linux, MacOS, and Windows environments with Python 3.10 or higher. ```bash pip install openml ``` -------------------------------- ### Launch API v2 Docker Services Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Build and start the Docker container stack for the API v2 (FastAPI) backend. ```bash docker compose --profile all up ``` -------------------------------- ### Run All Tests Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Execute all tests in the repository to verify your installation and changes. For Windows, ensure pytest is in your PATH. ```bash pytest tests ``` -------------------------------- ### Configure openml-python Client for Local API v1 Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Set the OpenML client to point to the local Docker instance of API v1 and use the default API key. This example also demonstrates testing flow publication. ```python import openml from openml_sklearn.extension import SklearnExtension from sklearn.neighbors import KNeighborsClassifier # Configure client to use local Docker instance openml.config.server = "http://localhost:8080/api/v1/xml" openml.config.apikey = "AD000000000000000000000000000000" # Test flow publication clf = KNeighborsClassifier(n_neighbors=3) extension = SklearnExtension() knn_flow = extension.model_to_flow(clf) knn_flow.publish() ``` -------------------------------- ### Run OpenML-Python Docker Container Source: https://github.com/openml/openml-python/blob/main/docs/details.md Execute the latest development version of openml-python within a Docker container. Ensure Docker is installed and configured. ```bash docker run -it openml/openml-python ``` -------------------------------- ### Download Task and Dataset Source: https://github.com/openml/openml-python/blob/main/README.md Fetches a specific machine learning task by its ID and then retrieves the associated dataset. It also demonstrates how to get data splits for cross-validation. ```python import openml task = openml.tasks.get_task(31) dataset = task.get_dataset() X, y, categorical_indicator, attribute_names = dataset.get_data(target=task.target_name) # get splits for the first fold of 10-fold cross-validation train_indices, test_indices = task.get_train_test_split_indices(fold=0) ``` -------------------------------- ### Build Documentation (Windows) Source: https://github.com/openml/openml-python/blob/main/docker/readme.md Builds documentation for the 'develop' branch, mounting an output directory on Windows. ```bash docker run --mount type=bind,source="E:\files/output",destination="/output" openml/openml-python doc develop ``` -------------------------------- ### Build Documentation (Linux) Source: https://github.com/openml/openml-python/blob/main/docker/readme.md Builds documentation for the 'develop' branch, mounting an output directory on Linux. ```bash docker run --mount type=bind,source="./output",destination="/output" openml/openml-python doc develop ``` -------------------------------- ### Build Docs with Local Repo and Output Mount Source: https://github.com/openml/openml-python/blob/main/docker/readme.md Builds documentation using a local repository and mounts an output directory. ```bash docker run --mount type=bind,source="./output",destination="/output" --mount type=bind,source="/Users/pietergijsbers/repositories/openml-python",destination="/code" openml/openml-python doc ``` -------------------------------- ### Clone and Navigate Repository Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Clone your fork of the openml-python repository and navigate into the project directory. ```bash git clone git@github.com:YourLogin/openml-python.git cd openml-python ``` -------------------------------- ### Checkout Main Branch Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Switch to the main branch of the repository. ```bash git checkout main ``` -------------------------------- ### Use Local Repository for Tests (Linux) Source: https://github.com/openml/openml-python/blob/main/docker/readme.md Runs tests using a local repository mounted into the container on Linux. ```bash docker run --mount type=bind,source="/Users/pietergijsbers/repositories/openml-python",destination="/code" openml/openml-python test ``` -------------------------------- ### Use Local Repository for Tests (Windows) Source: https://github.com/openml/openml-python/blob/main/docker/readme.md Runs tests using a local repository mounted into the container on Windows. ```bash docker run --mount type=bind,source="E:\repositories/openml-python",destination="/code" openml/openml-python test ``` -------------------------------- ### Run Local Script Source: https://github.com/openml/openml-python/blob/main/docker/readme.md Executes a local Python script by mounting it into the container's /openml directory. ```bash docker run -v PATH/TO/FILE:/openml/MY_SCRIPT.py openml/openml-python MY_SCRIPT.py ``` -------------------------------- ### Resolve Container Conflicts and Launch API v1 Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Stop and remove any existing API v2 containers to prevent name conflicts, then launch the API v1 services. ```bash docker compose --profile all down docker compose --profile all up -d ``` -------------------------------- ### Run Unit Tests Source: https://github.com/openml/openml-python/blob/main/docker/readme.md Executes unit tests for the 'develop' branch within the container. ```bash docker run openml/openml-python test develop ``` -------------------------------- ### Initialize Conda Environment for openml-python Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Create and activate a new Conda virtual environment specifically for developing the openml-python library. ```bash conda create -n openml-python-dev python=3.12 conda activate openml-python-dev ``` -------------------------------- ### Clone OpenML Server API (API v2) Repository Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Retrieve the source code for the new Python-based API v2 backend. ```bash git clone https://github.com/openml/server-api cd server-api ``` -------------------------------- ### Run Pre-commit Checks Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Execute pre-commit checks locally to ensure code style and formatting compliance. This is equivalent to running `pre-commit run --all-files` on systems without `make`. ```bash $ make check ``` ```bash $ pre-commit run --all-files ``` -------------------------------- ### Clone OpenML Services Repository Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Retrieve the source code for the OpenML services (API v1). Navigate into the cloned directory. ```bash git clone https://github.com/openml/services cd services ``` -------------------------------- ### Clone openml-python SDK Repository Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Retrieve the source code for the OpenML Python client library. ```bash git clone https://github.com/openml/openml-python cd openml-python ``` -------------------------------- ### Run Specific Unit Tests Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Execute specific tests by providing the file path, test class, or individual test method. This helps in isolating and debugging issues. ```bash pytest tests/test_datasets/test_dataset.py ``` ```bash pytest tests/test_datasets/test_dataset.py::OpenMLDatasetTest ``` ```bash pytest tests/test_datasets/test_dataset.py::OpenMLDatasetTest::test_get_data ``` -------------------------------- ### Run All Pytest Tests Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Execute the entire test suite for the openml-python SDK. ```bash pytest ``` -------------------------------- ### Configure API v1 File Permissions Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Set correct ownership for the data directory to allow the PHP container to write files. If www-data user is not present, use 777 permissions as a fallback. ```bash chown -R www-data:www-data data/php ``` ```bash chmod -R 777 data/php ``` -------------------------------- ### Iterate Through Benchmarking Suite Tasks Source: https://github.com/openml/openml-python/blob/main/README.md Retrieves a predefined OpenML benchmarking suite and iterates through the task IDs within that suite to fetch individual tasks. ```python import openml suite = openml.study.get_suite("amlb-classification-all") # Get a curated list of tasks for classification for task_id in suite.tasks: task = openml.tasks.get_task(task_id) ``` -------------------------------- ### Read Docker Image Readme Source: https://github.com/openml/openml-python/blob/main/docker/readme.md View the readme file within a specific Docker image tag. ```bash docker run --entrypoint=/bin/cat openml/openml-python:TAG readme.md ``` -------------------------------- ### Add and Commit Changes Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Stage modified files using git add and commit them with a descriptive message. ```bash git add modified_files git commit ``` -------------------------------- ### Execute Python Command Source: https://github.com/openml/openml-python/blob/main/docker/readme.md Runs a specific Python command within the container to check the OpenML-Python version. ```bash docker run openml/openml-python -c "import openml; print(openml.__version__)" ``` -------------------------------- ### Download Dataset by Name Source: https://github.com/openml/openml-python/blob/main/README.md Retrieves a dataset from OpenML using its string name. It then extracts the data, target variable, and attribute names. ```python import openml dataset = openml.datasets.get_dataset("credit-g") # or by ID get_dataset(31) X, y, categorical_indicator, attribute_names = dataset.get_data(target="class") ``` -------------------------------- ### Push Changes to GitHub Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Push your local feature branch to your GitHub account to prepare for a pull request. ```bash git push -u origin my-feature ``` -------------------------------- ### Set Admin Key on Linux/macOS Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Sets the OPENML_TEST_SERVER_ADMIN_KEY environment variable using bash. This is required for tests needing administrative privileges on Linux or macOS. ```bash export OPENML_TEST_SERVER_ADMIN_KEY="admin-key" ``` -------------------------------- ### Set Admin API Key for Tests Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Export the admin API key as an environment variable to run tests that require admin privileges on the test server. This is typically for core contributors. ```bash # For windows $env:OPENML_TEST_SERVER_ADMIN_KEY = "admin-key" ``` ```bash # For linux/mac export OPENML_TEST_SERVER_ADMIN_KEY="admin-key" ``` -------------------------------- ### Create Feature Branch Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Create a new branch for your feature development. It's recommended to prepend the branch name with the type of changes (e.g., feature, fix, doc, maint). ```bash git checkout -b feature/my-feature ``` -------------------------------- ### Set Admin Key on Windows Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Sets the OPENML_TEST_SERVER_ADMIN_KEY environment variable using PowerShell. This is required for tests needing administrative privileges on Windows. ```shell $env:OPENML_TEST_SERVER_ADMIN_KEY = "admin-key" ``` -------------------------------- ### Run Pytest with Scikit-learn Marker Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Execute only the tests that require the scikit-learn library, using the `sklearn` pytest marker. ```bash pytest -m sklearn ``` -------------------------------- ### Run Pytest Excluding Production Server Tests Source: https://github.com/openml/openml-python/blob/main/docs/developer_setup.md Execute all tests except those that interact with the live OpenML production server, using pytest markers. ```bash pytest -m "not production_server" ``` -------------------------------- ### Diagnose Slow Tests with Pytest Source: https://github.com/openml/openml-python/blob/main/CONTRIBUTING.md Use pytest options to identify and analyze slow-running tests. This includes showing test durations, setting timeouts, and profiling specific components. ```bash # Show the 20 slowest tests (use 0 to list every test's duration) pytest tests --durations=20 ``` ```bash # Fail any test that exceeds the given timeout (requires pytest-timeout) pytest tests --timeout=600 ``` ```bash # Investigate only fixture/setup costs without actually running the tests pytest tests --setup-only ``` ```bash # Profile a specific module, class, or test pytest tests/test_datasets/test_dataset.py --durations=0 ``` ```bash # Skip the slow live-server tests while profiling locally pytest tests --durations=0 -m "not production_server and not test_server" ``` ```bash # Run the suite in parallel to reproduce CI behaviour (requires pytest-xdist) pytest tests -n 4 --dist=load --durations=0 ``` -------------------------------- ### OpenML-Python Bibtex Citation Source: https://github.com/openml/openml-python/blob/main/README.md Provides the Bibtex entry for citing the OpenML-Python library in scientific publications. This format is commonly used in LaTeX documents. ```bibtex @article{JMLR:v22:19-920, author = {Matthias Feurer and Jan N. van Rijn and Arlind Kadra and Pieter Gijsbers and Neeratyoy Mallik and Sahithya Ravi and Andreas Müller and Joaquin Vanschoren and Frank Hutter}, title = {OpenML-Python: an extensible Python API for OpenML}, journal = {Journal of Machine Learning Research}, year = {2021}, volume = {22}, number = {100}, pages = {1--5}, url = {http://jmlr.org/papers/v22/19-920.html} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.