Contribute#

Overall guidance on contributing to a PyAnsys library appears in Contributing in the PyAnsys developer’s guide. Ensure that you are thoroughly familiar with this guide before attempting to contribute to the FileTransfer Tool.

The following contribution information is specific to the FileTransfer Tool.

Install in development mode#

Installing the FileTransfer Tool in development mode allows you to modify the source and enhance it.

  1. Clone the repository and enter the newly created directory:

    git clone https://github.com/ansys/ansys-tools-filetransfer
    cd ansys-tools-filetransfer
    
  2. Install dependencies:

    python -m pip install pipx
    pipx ensurepath
    pipx install poetry
    pipx install pip
    pipx install tox
    

    The project uses Poetry to manage the development environment.

  3. Create a virtual environment and install the package with the development dependencies:

    poetry install
    
  4. Activate the virtual environment:

    poetry shell
    

Test#

You can run the tests for the FileTransfer Tool with either a local executable of the server or with a Docker container.

Unless you are contributing to development of the server, using a Docker container is recommended.

  1. Pull the Docker image:

    docker pull ghcr.io/ansys/tools-filetransfer:latest
    
  2. Run the tests with tox.

    For example, this command runs the test for Python 3.10:

    tox -e py310
    

Alternatively, you can run the tests directly via pytest. Ensure that the development virtual environment is activated:

poetry shell

Then, run the tests:

pytest

Running the tests directly via pytest also allows you to pass additional arguments. For example, this command runs the tests with a local executable of the server:

pytest --server-bin /path/to/server/executable

This command runs the tests with a different Docker image of the server:

pytest --server-image <image_name>

Build documentation#

You can build the documentation with this tox command:

tox -e doc

The resulting files are located in the doc/_build/html directory.

Run style checks#

The style checks use pre-commit and can be run using this tox command:

tox -e style

You can also configure the style checks to run automatically before each git commit with this command:

pre-commit install