Package: renku
A Python library for theRenku collaborative data science platform. It includes a CLI and SDK
for end-users as well as a service backend. It provides functionality for the
creation and management of projects and datasets, and simple utilities to
capture data provenance while performing analysis tasks.NOTE:renku-pythonis the python library and core service for Renku - itdoes
notstart the Renku platform itself - for that, refer to the Renku docs onrunning the platform.Renku for UsersInstallationRenku releases and development versions are available fromPyPI. You can install it using any tool that
knows how to handle PyPI packages. Our recommendation is to use:code:pipx.NoteWe do not officially support Windows at this moment. The way Windows
handles paths and symlinks interferes with some Renku functionality.
We recommend using the Windows Subsystem for Linux (WSL) to use Renku
on Windows.PrerequisitesRenku depends on Git under the hood, so make sure that you have Gitinstalled on your system.Renku also offers support to store large files inGit LFS, which is used by default and should be
installed on your system. If you do not wish to use Git LFS, you can run
Renku commands with the-Sflag, as inrenku -S <command>.  More
information on Git LFS usage in renku can be found in theData in Renkusection of the docs.Renku uses CWL to execute recorded workflows when callingrenku updateorrenku rerun. CWL depends on NodeJs to execute the workflows, so installingNodeJsis required if
you want to use those features.For development of the service,Dockeris recommended.pipxFirst,install pipxand make sure that the$PATHis correctly configured.$ python3 -m pip install --user pipx
$ python3 -m pipx ensurepathOncepipxis installed use following command to installrenku.$ pipx install renku
$ which renku
~/.local/bin/renkupipxinstalls Renku into its own virtual environment, making sure that it
does not pollute any other packages or versions that you may have already
installed.NoteIf you install Renku as a dependency in a virtual environment and the
environment is active, your shell will default to the version installed
in the virtual environment,notthe version installed bypipx.To install a development release:$ pipx install --pip-args pre renkupip$ pip install renkuThe latest development versions are available on PyPI or from the Git
repository:$ pip install --pre renku
# - OR -
$ pip install -e git+https://github.com/SwissDataScienceCenter/renku-python.git#egg=renkuUse following installation steps based on your operating system and preferences
if you would like to work with the command line interface and you do not need
the Python library to be importable.WindowsNoteWe don’t officially support Windows yet, but Renku works well in the Windows Subsystem for Linux (WSL).
As such, the following can be regarded as a best effort description on how to get started with Renku on Windows.Renku can be run using the Windows Subsystem for Linux (WSL). To install the WSL, please follow theofficial instructions.We recommend you use the Ubuntu 20.04 image in the WSL when you get to that step of the installation.Once WSL is installed, launch the WSL terminal and install the packages required by Renku with:$ sudo apt-get update && sudo apt-get install git python3 python3-pip python3-venv pipxSince Ubuntu has an older version of git LFS installed by default which is known to have some bugs when cloning
repositories, we recommend you manually install the newest version by followingthese instructions.Once all the requirements are installed, you can install Renku normally by running:$ pipx install renku
$ pipx ensurepathAfter this, Renku is ready to use. You can access your Windows in the various mount points in/mnt/and you can execute Windows executables (e.g.\*.exe) as usual directly from the
WSL (sorenku run myexecutable.exewill work as expected).DockerThe containerized version of the CLI can be launched using Docker command.$ docker run -it -v "$PWD":"$PWD" -w="$PWD" renku/renku-python renkuIt makes sure your current directory is mounted to the same place in the
container.CLI ExampleInitialize a Renku project:$ mkdir -p ~/temp/my-renku-project
$ cd ~/temp/my-renku-project
$ renku initCreate a dataset and add data to it:$ renku dataset create my-dataset
$ renku dataset add my-dataset https://raw.githubusercontent.com/SwissDataScienceCenter/renku-python/master/README.rstRun an analysis:$ renku run --name my-workflow -- wc < data/my-dataset/README.rst > wc_readmeTrace the data provenance:$ renku workflow visualize wc_readmeThese are the basics, but there is much more that Renku allows you to do with
your data analysis workflows. The full documentation will soon be available
at:https://renku-python.readthedocs.io/Renku as a ServiceThis repository includes arenku-coreRPC service written as aFlaskapplication that provides (almost) all of
the functionality of the Renku CLI. This is used to provide one of the backends
for theRenkuLabweb UI. The service can be deployed in
production as a Helm chart (seehelm-chart.Deploying locallyTo test the service functionality you can deploy it quickly and easily usingdocker-composeup[docker-compose](https://pypi.org/project/docker-compose/).
Make sure to make a copy of therenku/service/.env-examplefile and configure it
to your needs. The setup here is to expose the service behind a traefik reverse proxy
to mimic an actual production deployment. You can access the proxied endpoints athttp://localhost/api. The service itself is exposed on port 8080 so its endpoints
are available directly underhttp://localhost:8080.API DocumentationThe renku core service implements the API documentation as an OpenAPI 3.0.x spec.
You can retrieve the yaml of the specification itself with` $ renku service apispec `If deploying the service locally withdocker-composeyou can find the swagger-UI
underlocalhost/api/swagger. To send the proper authorization headers to the
service endpoints, click theAuthorizebutton and enter a valid JWT token and
a gitlab token with read/write repository scopes. The JWT token can be obtained by
logging in to a renku instance withrenku loginand retrieving it from your local
renku configuration.In a live deployment, the swagger documentation is available underhttps://<renku-endpoint>/swagger.
You can authorize the API by first logging into renku normally, then going to the
swagger page, clickingAuthorizeand picking theoidc (OAuth2, authorization_code)option. Leave theclient_idasswaggerand theclient_secretempty, select
all scopes and clickAuthorize. You should now be logged in and you can send
requests using theTry it outbuttons on individual requests.Developing RenkuFor testing the functionality from source it is convenient to installrenkuin editable mode usingpipx. Clone the repository and then do:$ pipx install \
    --editable \
    <path-to-renku-python>[all] \
    renkuThis will install all the extras for testing and debugging.If you already usepyenvto manage different python versions,
you may be interested in installingpyenv-virtualenvto
create an ad-hoc virtual environment for developing renku.Once you have created and activated a virtual environment for renku-python, you can use the usualpipcommands to install the required dependencies.$ pip install -e .[all]  # use `.[all]` for zshServiceDeveloping the service and testing its APIs can be done withdocker compose(see
“Deploying Locally” above).If you have a full RenkuLab deployment at your disposal, you can
usetelepresencev1 to develop and debug locally.
Just run thestart-telepresence.shscript and follow the instructions.
Mind that the script doesn’t work with telepresence v2.Running testsWe usepytestfor running tests.
You can use ourrun-tests.shscript for running specific set of tests.$ ./run-tests.sh -hWe lint the files usingblackandisort.Using External DebuggersLocal MachineTo runrenkuvia e.g. theVisual Studio Code debuggeryou need run it via
the python executable in whatever virtual environment was used to installrenku. If there is a package
needed for the debugger, you need to inject it into the virtual environment first, e.g.:$ pipx inject renku ptvsdFinally, runrenkuvia the debugger:$ ~/.local/pipx/venvs/renku/bin/python -m ptvsd --host localhost --wait -m renku.ui.cli <command>If using Visual Studio Code, you may also want to set theRemote AttachconfigurationPathMappingsso that it will find your source code, e.g.{
    "name": "Python: Remote Attach",
    "type": "python",
    "request": "attach",
    "port": 5678,
    "host": "localhost",
    "pathMappings": [
        {
            "localRoot": "<path-to-renku-python-source-code>",
            "remoteRoot": "<path-to-renku-python-source-code>"
        }
    ]
}