JMSLab / Template

Template for research repository using scons.
9 stars 1 forks source link

JMSLab Template

A template for research projects developed by JMSLab.

Prerequisites

In addition, each project may use other specialized tools. For the working example in this template, install:

Repository structure

Quick start

  1. Open the command-line and clone the repository. For example,

    git clone https://github.com/JMSLab/Template ProjectName
    cd ProjectName
  2. Create a symbolic link called datastore to a local copy the project's datastore, if one exists for the project (e.g. a Dropbox or Google Drive folder).

    • Do not link a "live" copy of the datastore (i.e. one that is synchronized to the internet). Work with a local, off-line copy before modifying the live copy; otherwise the data may get unintentionally overwritten for everyone using the datastore.
  3. Install dependencies:

    pip install -r source/lib/requirements.txt

    (If using conda, run conda install --file source/lib/requirements.txt.) Requirements for other languages, should there be any, will be found in source/lib/requirements.{ext} with {ext} equal to do (Stata), r (R), m (Matlab), and so on.

  4. Make sure that all the required program executables are in your system's path.

    • The default names that SCons assumes for the programs are in source/lib/JMSLab/builders/executables.yml.

    • To have SCons use a custom executable name or path, define a command-line (environment) variable named JMSLAB_EXE_PROGRAM. e.g. On Windows, SET JMSLAB_EXE_STATA=StataSE.exe or SET JMSLAB_EXE_STATA=C:\Program Files (x86)\Stata16\StataSE.exe.

  5. To compile the project, open the command-line and run scons from the project's root folder.

    • To run a given script or create a given file, run scons path/to/script_or_file; this will recursively run all the dependencies required to run the script or create the file. e.g. scons output/derived/wb_clean/gdp_education.csv.

SConscript files

In order to integrate a new script into the SCons build, you need to modify the SConscript file in the corresponding source/ sub-folder. For example, to add source/derived/wb_clean/takelogs.do to the SCons build, add an entry to source/derived/SConscript. In this case:

target = ['#output/derived/wb_clean/gdp_education_logs.csv']
source = ['#source/derived/wb_clean/takelogs.do',
          '#output/derived/wb_clean/gdp_education.csv']
env.Stata(target, source)

Citations and expectations for usage

This template is based on gslab-econ/Template/v4.1.3 and gslab-python/v4.1.4.

It was designed for use in JMSLab. You are welcome to use it in your own research, as long as you (i) let us know that you plan to do this and (ii) agree to help maintain the template in the future.

Use in reproducible research

A research repository based on this template was used successfully in a first-try replication by a third party contracted to the American Economic Association in June 2022.