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

[skip ci] 📝 Improve Documentation #913

Merged
merged 14 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 25 additions & 31 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
.. highlight:: shell

============
=============
Contributing
============
=============

Contributions are welcome, and they are greatly appreciated! Every little bit
helps, and credit will always be given.
Contributions are welcome and greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Expand All @@ -26,21 +25,17 @@ If you are reporting a bug, please include:
Fix Bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
wanted" is open to whoever wants to implement it.
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it.

Implement Features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.
Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

TIA Toolbox could always use more documentation, whether as part of the
official TIA Toolbox docs, in docstrings, or even on the web in blog posts,
articles, and such.
TIA Toolbox could always use more documentation, whether as part of the official TIA Toolbox docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~
Expand All @@ -50,9 +45,8 @@ The best way to send feedback is to file an issue at https://github.com/TissueIm
If you are proposing a feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)
* Keep the scope as narrow as possible to make it easier to implement.
* Remember that this is a volunteer-driven project, and contributions are welcome :)

Get Started!
------------
Expand All @@ -64,7 +58,7 @@ Ready to contribute? Here's how to set up ``tiatoolbox`` for local development.

$ git clone [email protected]:your_name_here/tiatoolbox.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
3. Install your local copy into a virtual environment. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::

$ mkvirtualenv tiatoolbox
$ cd tiatoolbox/
Expand All @@ -76,13 +70,18 @@ Ready to contribute? Here's how to set up ``tiatoolbox`` for local development.

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass flake8 and the
tests::
5. When you're done making changes, check that your changes pass pre-commit and the tests::

$ flake8 tiatoolbox tests
$ pre-commit run --all-files
$ python setup.py test or pytest

To get flake8, just pip install them into your virtualenv.
To get `pre-commit <https://pre-commit.com/#install>`_, just pip install it into your virtual environment using::

$ pip install pre-commit

To set up the git hook for pre-commit, run the following command after installing pre-commit::

$ pre-commit install

6. Commit your changes and push your branch to GitHub::

Expand All @@ -98,20 +97,15 @@ Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.8, 3.9 and 3.10, and for PyPy. Check
https://travis-ci.com/tialab/tiatoolbox/pull_requests
and make sure that the tests pass for all supported Python versions.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the pull request description.
3. The pull request should work for Python 3.9, 3.10, 3.11, and 3.12, and for PyPy. Check https://github.com/TissueImageAnalytics/tiatoolbox/actions/workflows/python-package.yml and make sure that the tests pass for all supported Python versions.

Tips
----

To run a subset of tests::

$ pytest tests.test_tiatoolbox

$ pytest tests.test_tiatoolbox

Deploying
---------
Expand All @@ -120,8 +114,8 @@ A reminder for the maintainers on how to deploy.
Make sure all your changes are committed (including an entry in HISTORY.rst).
Then run::

$ poetry version patch # use: "poetry version --help" for other options
$ git push
$ git push --tags
$ poetry version patch # use: "poetry version --help" for other options
$ git push
$ git push --tags

Travis will then deploy to PyPI if tests pass.
GitHub Actions will then deploy to PyPI if tests pass.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ or

### License

The source code TIA Toolbox (tiatoolbox) as hosted on GitHub is released under the [BSD-3-Clause license](https://github.com/TissueImageAnalytics/tiatoolbox/blob/develop/LICENSE). The full text of the licence is included in [LICENSE](https://raw.githubusercontent.com/TissueImageAnalytics/tiatoolbox/develop/LICENSE).
The source code TIAToolbox (tiatoolbox) as hosted on GitHub is released under the [BSD-3-Clause license](https://github.com/TissueImageAnalytics/tiatoolbox/blob/develop/LICENSE). The full text of the licence is included in [LICENSE](https://raw.githubusercontent.com/TissueImageAnalytics/tiatoolbox/develop/LICENSE).

Models weights are dependent on the datasets that they were trained on. Please refer to the [documentation](https://tia-toolbox.readthedocs.io/en/latest/pretrained.html) for more details.

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ def all_but_ipynb(dir_path, contents):
# Replace the target string
file_data = file_data.replace(".rst", ".html")
file_data = file_data.replace(".ipynb", ".html")
file_data = file_data.replace("](./", "](./jnb/")
file_data = file_data.replace("](./", "](./_notebooks/jnb/")
file_data = file_data.replace("../docs/", "./")

# Write the file out again
Expand Down
95 changes: 43 additions & 52 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,26 @@ Installation

Prerequisites
=============
The prerequisites for tiatoolbox installation are OpenSlide binaries and OpenJpeg version 2.3.0 or above.
Please follow the instructions below to install prerequisite software according to the platform you are using.

The prerequisites for TIAToolbox installation are OpenSlide binaries and OpenJPEG version 2.3.0 or above. Please follow the instructions below to install the prerequisite software according to your platform.

Linux (Ubuntu)
--------------
On Linux the prerequisite software can be installed using the command

On Linux, the prerequisite software can be installed using the following command:

.. code-block:: console

$ apt-get -y install libopenjp2-7-dev libopenjp2-tools openslide-tools

The same command is used when working on the Colab or Kaggle platforms.
When working on Google Colab, we remove the packages ``datascience`` and ``albumentations`` because they conflict
and produce an error message.
The same command is used when working on the Colab or Kaggle platforms. When working on Google Colab, we remove the packages ``datascience`` and ``albumentations`` because they conflict and produce an error message.

Windows (10+)
-------------------
1. Download OpenSlide binaries from `this page <https://openslide.org/download/>`_. Extract the folder and add ``bin`` and ``lib`` subdirectories to
Windows `system path <https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537574(v=office.14)>`_. If you are using a conda environment you can also copy ``bin`` and ``lib`` subdirectories to ``[Anaconda Installation Path]/envs/[tiatoolbox-environment]/Library/``.
-------------

2. Install OpenJPEG. The easiest way is to install OpenJpeg is through conda
using
1. Download OpenSlide binaries from `this page <https://openslide.org/download/>`_. Extract the folder and add the ``bin`` and ``lib`` subdirectories to the Windows `system path <https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537574(v=office.14)>`_. If you are using a conda environment, you can also copy the ``bin`` and ``lib`` subdirectories to ``[Anaconda Installation Path]/envs/[tiatoolbox-environment]/Library/``.

2. Install OpenJPEG. The easiest way to install OpenJPEG is through conda:

.. code-block:: console

Expand All @@ -37,7 +35,7 @@ using
macOS
-----

On macOS there are two popular package managers, `homebrew`_ and `macports`_.
On macOS, there are two popular package managers, `homebrew`_ and `macports`_.

.. _homebrew: https://brew.sh/
.. _macports: https://www.macports.org/
Expand All @@ -56,26 +54,26 @@ MacPorts

$ port install openjpeg openslide


Installing Stable Release
=========================

Please note that TIAToolbox is tested for python version 3.9, 3.10, 3.11 and 3.12.
Please note that TIAToolbox is tested for Python versions 3.9, 3.10, 3.11, and 3.12.

Recommended
-----------

To install TIAToolbox, run this command in your terminal after you have installed the prerequisite software:

.. code-block:: console

$ pip install tiatoolbox

This is the preferred method to install TIA Toolbox, as it will always install the most recent stable release.
This is the preferred method to install TIAToolbox, as it will always install the most recent stable release.

Upgrade
-------

To upgrade an existing version of tiatoolbox to the latest stable release, run this command in your terminal:
To upgrade an existing version of TIAToolbox to the latest stable release, run this command in your terminal:

.. code-block:: console

Expand All @@ -84,21 +82,19 @@ To upgrade an existing version of tiatoolbox to the latest stable release, run t
Without Dependencies
--------------------

If you already have setup a Python environment with all the pre-requisite software and dependencies installed and you would like to keep the existing versions of these dependencies, run this command in your terminal:
If you already have a Python environment set up with all the prerequisite software and dependencies installed and you would like to keep the existing versions of these dependencies, run this command in your terminal:

.. code-block:: console

$ pip install --no-deps tiatoolbox

If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.
If you don't have `pip`_ installed, this `Python installation guide`_ can guide you through the process.

.. _pip: https://pip.pypa.io
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/


Alternative Method(s)
=====================
Alternative Methods
===================

Using Anaconda
--------------
Expand All @@ -115,13 +111,12 @@ or

$ mamba install tiatoolbox

Please note that conda-forge installation support is limited on Windows as OpenSlide binaries are not supported on official conda channels. An alternate way to install using conda on Windows could be to install it in `WSL2 with CUDA support <https://docs.microsoft.com/en-us/windows/ai/directml/gpu-cuda-in-wsl>`_. In some cases, WSL2 runs faster on Python code, and therefore we **recommend** this option.

Please note that conda-forge installation support is limited on Windows as openslide binaries are not supported on official conda channels. An alternate way to install using conda on Windows could be to install it in `WSL2 with CUDA support <https://docs.microsoft.com/en-us/windows/ai/directml/gpu-cuda-in-wsl>`_. In some cases, WSL2 runs faster on Python codes and therefore we **recommend** this option.

From sources
From Sources
------------

The sources for TIA Toolbox can be downloaded from the `Github repo`_.
The sources for TIAToolbox can be downloaded from the `GitHub repo`_.

You can either clone the public repository:

Expand All @@ -141,69 +136,65 @@ Once you have a copy of the source, you can install it with:

$ python setup.py install


.. _Github repo: https://github.com/TissueImageAnalytics/tiatoolbox.git
.. _GitHub repo: https://github.com/TissueImageAnalytics/tiatoolbox.git
.. _tarball: https://github.com/TissueImageAnalytics/tiatoolbox/tarball/master

Using Docker
------------

To run TIA toolbox in an isolated environment, use our `Docker image <https://github.com/tissueimageanalytics/tiatoolbox-docker/pkgs/container/tiatoolbox>`_ . We host different Dockerfiles in our github repository `tiatoolbox-docker <https://github.com/TissueImageAnalytics/tiatoolbox-docker>`_. Please report any issues related to the docker image in the repository `tiatoolbox-docker <https://github.com/TissueImageAnalytics/tiatoolbox-docker>`_.
To run TIAToolbox in an isolated environment, use our `Docker image <https://github.com/tissueimageanalytics/tiatoolbox-docker/pkgs/container/tiatoolbox>`_. We host different Dockerfiles in our GitHub repository `tiatoolbox-docker <https://github.com/TissueImageAnalytics/tiatoolbox-docker>`_. Please report any issues related to the Docker image in the repository `tiatoolbox-docker <https://github.com/TissueImageAnalytics/tiatoolbox-docker>`_.

After `installing Docker <https://docs.docker.com/get-docker/>`_ (or Docker Desktop), you can use our TIA toolbox image in 3 different ways.
After `installing Docker <https://docs.docker.com/get-docker/>`_ (or Docker Desktop), you can use our TIAToolbox image in three different ways.

Use the Pre-Built Docker Image
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TIAToolbox provides pre-built docker containers which can be downloaded using the instructions below:

1. Pull the Image From Github Container Registry
""""""""""""""""""""""""""""""""""""""""""""""""""""
TIAToolbox provides pre-built Docker containers which can be downloaded using the instructions below:

1. Pull the Image From GitHub Container Registry:

.. code-block:: console

$ docker pull ghcr.io/tissueimageanalytics/tiatoolbox:latest

2. Use the Pre-Built Docker Image as a Base Image in a Dockerfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.. code-block:: console
2. Use the Pre-Built Docker Image as a Base Image in a Dockerfile:

$ FROM ghcr.io/tissueimageanalytics/tiatoolbox:latest
.. code-block:: dockerfile

Build the image locally
FROM ghcr.io/tissueimageanalytics/tiatoolbox:latest

Build the Image Locally
^^^^^^^^^^^^^^^^^^^^^^^
1. Navigate to the Dockerfile that you want to use,
based on the Python version and Operating System that you prefer

2. Build the
Docker image
1. Navigate to the Dockerfile that you want to use, based on the Python version and Operating System that you prefer.

2. Build the Docker image:

.. code-block:: console

$ docker build -t <IMAGE_NAME> .

3. Check that the image
has been created
3. Check that the image has been created:

.. code-block:: console

$ docker images

4. Deploy the image
as a Docker container
4. Deploy the image as a Docker container:

.. code-block:: console

$ docker run -it --rm --name <CONTAINER_NAME> <IMAGE_NAME>

5. Connect to the
running container
5. Connect to the running container:

.. code-block:: console

$ docker exec -it <CONTAINER_NAME> bash

To add your own script and run it through the Docker container, first copy your script into the docker environment and then execute it.
To add your own script and run it through the Docker container, first copy your script into the Docker environment and then execute it:

.. code-block:: console
.. code-block:: dockerfile

$ COPY /path/to/<script>.py .
$ CMD ["python3", "<script>.py"]
COPY /path/to/<script>.py .
CMD ["python3", "<script>.py"]
Loading