Requirements for Code Publication

Maximilian Dolling

eScience Center - GFZ

18.05.2020

Checklist

    just look, don't touch

  1. check and add license
  2. make it a git repository
  3. use code hosting platform
  4. add citation file
  5. get DOI

    presenting yourself

  1. use a style guide
  2. add authors list
  3. document your code
  4. run/make script(s)
  5. (test your software)

    community development

  1. test your software
  2. add contribution guide
Style is important
                    
                        def GeT_SuMOf_int(Int A, int B): INT ResulT = A+B; reTurn ResulT
                    
                
Style is important
                    
                        def get_sum_of_int(int A, int B):
                            int result = A+B
                            return result
                    
                
Comments
                    
                        def get_python_libraries_license(libraries_dict):
                            license_dict = {'licenses': {},
                                            'unknowns': {}}
                            for lib in libraries_dict:
                                if lib[0:4] == 'http' or '.' in lib or '/' in lib:
                                    license_dict['unknowns'][lib] = 'unknown location'
                                    continue
                    
                
Comments
                    
                        def get_python_libraries_license(libraries_dict):
                            license_dict = {'licenses': {},
                                            'unknowns': {}}
                            for lib in libraries_dict:
                                if lib[0:4] == 'http' or '.' in lib or '/' in lib:
                                    license_dict['unknowns'][lib] = 'unknown location'
                                    continue
                    
                
Comments
                    
                        def get_python_libraries_license(libraries_dict):
                            '''
                            This function requests the license of a library on PyPI.
                            It marks all libraries that are not hosted on PyPI as 'unknown license'.
                            Assumes requirements.txt is valid.

                            :param arg1: dict of used libraries and their versions
                            :type arg1: dict{lib_name: list[version1, version2]}
                            :return: dict of used libraries and their license
                            :rtype: dict{lib_name: list[license1, license2]}
                            '''

                            license_dict = {'licenses': {},
                                            'unknowns': {}}
                            for lib in libraries_dict:
                                # handle not hosted on PyPI
                                if lib[0:4] == 'http' or '.' in lib or '/' in lib:
                                    license_dict['unknowns'][lib] = 'unknown location'
                                    continue
                    
                
runscript
                    
                        #!/usr/bin/env bash

                        # change to path of this script
                        # shellcheck disable=SC2046
                        cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ) || exit 1

                        # remove db files from local runs
                        rm -rf ./service_database/app/migrations
                        rm -rf ./service_database/app/app.db

                        # set device (enp0s31f6) ip as environment variable
                        HOST_IP=$(ip addr show enp0s31f6 | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/')

                        # put host ip into global environment variables conf
                        sed "s/HOST_IP=/HOST_IP=$HOST_IP/g" config/global.env > global.env

                        # start images with docker compose
                        docker-compose up -d --build
                    
                
tests
                    
                        def multiply(int A, int B):
                            return A**B
                    
                    
                        def test_multiply():
                            assert multiply(3,13) == 39
                            assert raiseException(multiply(1.0, 2), wrongTypeException)
                    
                
tests
                    
                        def test_login_missing_field(selenium):
                            """
                            test login function with missing input and alerts
                            """

                            selenium.delete_all_cookies()

                            """
                            no password
                            """
                            selenium.get(app_url)
                            assert 'RSE@GFZ' in selenium.title
                            assert selenium.current_url == app_url + '/'
                            username = selenium.find_element_by_name('username')
                            submit = selenium.find_element_by_name('submit')
                            username.clear()
                            username.send_keys("foo")
                            submit.click()
                            warning = selenium.find_element_by_id('password_error')
                    
                

    just look, don't touch

  1. check and add a license
  2. make it a git repository
  3. use a code hosting platform
  4. get a DOI
  5. add a citation file

    presenting yourself

  1. use a style guide
  2. add a authors list
  3. document your code
  4. run / make script(s)
  5. (test your software)

    community development

  1. test your software
  2. add contribution guide