Dev_Settings and Configuration

William French edited this page Oct 21, 2014 · 4 revisions

Settings

The package django-configurations provides a class-based approach to Django settings. For CodaLab, the manage.py and wsgi.py files have been modified to support this extra capability.

The settings are located in codalab/codalab/settings/. There is a base and default set of settings. For local development, you'll need to create a new local.py. This overrides default settings and is used only for developing on a local computer. For server deployments, create a deploy.py file to store configuration settings. To find out more about configuring Django, read the following documentation: https://django-configurations.readthedocs.org/en/latest/#usage-patterns

There is a sample configuration file in settings/ named local_sample.py which demonstrates the typical settings that are needed for a particular environment. You can use this as a basis for creating your own customized settings files. The file base.py contains the majority of the settings and is typically updated when functionality is added and core packages need updating. If one wishes to test using other third-party Django apps, create a custom local.py file for the apps. It is recommended to use a custom local.py rather than updating base.py.

The local.py and deploy.py files are never checked in to the repository. For server deployments, the files need to be created with the appropriate settings and deployed separately from the repository.

Configuration

A package named config_gen is used to templatize configuration files needed for deployment and testing. The folder codalab/config/templates contains the templates for the configuration files. Note that not all of these files may be used for a particular configuration. To generate configuration files, run the following command:

python manage.py config_gen

The generated files are output to \codalab\config\generated.

The configuration files are built by using templates defined in the following

You can configure the location of the templates and the generated files by updating the CONFIG_GEN_TEMPLATES_DIR and CONFIG_GEN_GENERATED_DIR parameters defined in \codalab\settings\base.py.


Azure

You can use Azure services with Django, including:

  • SQL Azure
  • Blob storage
  • Azure service bus

SQL Azure

SQL Azure is similar to Microsoft SQL Server, but has some slightly different options for connecting to the database.

You will need to configure a SQL Database if one does not already exist. You can use the Azure management console to do this. During the process you'll need to provide (and record) settings such as the server name, database name, user, and so on. You will need to update your configuration files with these values. Be mindful of the user name, which needs to be in the format, username@server (servername, not the fully qualified host name). If you are connecting to the database from outside the Azure services under the subscription, in the Management console from the Dashboard for the database server select "Manage allowed IP addresses" and add the appropriate entries to allow access from the outside.

Windows Specifics

Requirements:

In the case of Windows Server 2012, select Tools->ODBC Datasources from the Tools tab. You need to set up a driver if the SQL Server driver does not appear. Next you will need to set up a Datasource using one of the drivers, using the settings and credentials for the database server, or alternatively the settings provided by a DBA managing the databases.

You will need to configure the settings for the SQL Azure database and the ODBC datasource(s) in a deploy.py or local.py configuration in codalab/codalab/settings/ using the settings described in codalab/codalab/settings/local_examples.py as a base for your own configuration.

Linux Specifics

Ubuntu has all the requirements available assuming version 13.04 or later is used:

  • freetds-dev
  • unixodbc-dev
  • tdsodbc Python dependencies:
  • pyodbc
  • django-pyodbc-azure

pip install pyodbc django-pyodbc-azure

You will need to update either the local.py or deploy.py settings file in codalab/codalab/settings/ using the settings described in codalab/codalab/settings/local_examples.py as a base for your own configuration.