Configuring Trains for Trains Server

After deploying Trains Server, you must configure Trains for it by either:

  • Creating a Trains configuration file using our interactive setup.
  • Editing the existing Trains configuration file, if one exists.

    Why would a Trains configuration file already exist?

    Trains and Trains Agent use the same configuration file, but not all the same configuration options. If you previously installed and configure Trains Agent, you may have an existing configuration file.

Creating a Trains configuration file

Use our trains-init setup wizard to create a Trains configuration file.

To create a Trains configuration file:

  1. Open a terminal session in Linux or a command prompt session in Microsoft Windows.
  2. In your terminal session, run the setup wizard by executing the following command:
    trains-init
    If the setup wizard's response indicates you already have a configuration file, you must edit it. The wizard does not edit or overwrite existing configuration files.
  3. At the prompt, enter the URL for your Trains Server web server.

    You must use a secure protocol, "https". Do not use "http".

    Enter the url of the trains-server’s Web service, for example: http://localhost:8080
    
    Web Application Host configured to: []
  4. Enter the API server (press Enter to accept the default value which is based on your previous response):
    API Host configured to: 
  5. Enter the file server (press Enter to accept the default value which is based on your previous response):
    File Store Host configured to:
    The wizard responses with your configuration and directs you to your Trains Server's, Trains Web-App to create Trains credentials.
    TRAINS Hosts configuration:
    Web App: <your web server url>
    API: <your api server url>
    File Store: <your file server url>
    
    Please create new credentials using the web app: <your web server url>/profile
    In the Admin page, press "Create new credentials", then press "Copy to clipboard"
    
    Paste credentials here:
  6. At the command prompt Paste credentials here:, copy and paste the Trains credentials you create as follows:
    1. Click the hyperlink for your Trains Server, Trains Web-App.
    2. If a login is required, login.

      Why would a login not be required?

      If your Trains Server is not configured for web login authentication, no login is required. You can add web login authentication, see Configuring Web Login Authentication on the "Configuring Trains Server" page.

    3. Click the PROFILE page.
    4. Click Create new credentials.
    5. Click Copy to clipboard.
    6. In your terminal session, paste your credentials and press Enter.

    The configuration is verified. The location of your configuration file appears.

    Verifying credentials ...
    Credentials verified!
    
    New configuration stored in /home/<username>/trains.conf
    TRAINS setup completed successfully.

Your Trains configuration file is saved. Its location depends upon your operating system:

  • Linux - ~/trains.conf
  • Mac - $HOME/trains.conf
  • Windows - \User\<username>\trains.conf

Editing a Trains configuration file

If a Trains configuration file already exists, edit it and add an api section containing your Trains Server web server, API server, and file server URLs, and your Trains credentials from the Trains Web-App.

Prerequisites

The URLs for your Trains Server are required:

  • Trains Server web server
  • Trains Server API server
  • Trains Server file server

These may be localhost, your domain, or a sub-domain of your domain.

To edit a Trains configuration file:

  1. Open your Trains configuration file for editing. Depending upon your operating system, it is:
    • Linux - ~/trains.conf
    • Mac - $HOME/trains.conf
    • Windows - \User\<username>\trains.conf
  2. Add an api section to the configuration file containing the following (for a complete configuration file example, see the trains.conf sample in the trains repository):
    api {
        # server URLs
        api_server: "<api_server_url>"
        web_server: "<web_server_url>"
        files_server: "<file_server_url>"
    
        # Credentials are generated using the webapp
        credentials {"access_key": "******************", "secret_key": "*******************"}
        }

    For example:

    • To use localhost:
      api {
            # API server on port 8008
            api_server: "http://localhost:8008"
            # web_server on port 8080
            web_server: "http://localhost:8080"
            # file server on port 8081
            files_server: "http://localhost:8081"
        }
    • To use a domain named mydomain.com:
      api {
          api_server: "https://api.mydomain.com:8008"
          web_server: "https://app.mydomain.com:8080"
          files_server: "https://files.mydomain.com:8081"
      }
    • To use a sub-domain named trains.mydomain.com (if you use a sub-domain, no port is required):
      api {
          api_server: "https://api.trains.mydomain.com"
          web_server: "https://app.trains.mydomain.com"
          files_server: "https://files.trains.mydomain.com"
      }

      Configuring Trains Server for sub-domains

      To configure sub-domains on Trains Server, see Configuring Sub-domains and load balancers on the "Configuring Trains Server" page.

  3. In the sdk.storage.cache section, add the size section highlighted below:
    
    sdk {
        # TRAINS - default SDK configuration
    
        storage {
            cache {
                # Defaults to system temp folder / cache
                default_base_dir: "~/.trains/cache"
    
    size { # max_used_bytes = -1 min_free_bytes = 10GB # cleanup_margin_percent = 5% }
    } direct_access: [ # Objects matching are considered to be available for direct access, i.e. they will not be downloaded # or cached, and any download request will return a direct reference. # Objects are specified in glob format, available for url and content_type. { url: "file://*" } # file-urls are always directly referenced ] }
  4. Save your Trains configuration file. Trains is now configured for your Trains Server.

Next Steps

  • You can now use the Trains Python Client Package in your Python experiment scripts and your Trains Server. When you run an experiment script, the experiment is stored in your Trains Server.
  • If you install and configure Trains Agent for your Trains Server, you can use workers and queues to manage your experimentation.