dodo.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # define tasks for UNFCCC data repository
  2. from doit import get_var
  3. # Tasks for getting submissions and downloading them
  4. def task_update_bur():
  5. """ Update list of BUR submissions """
  6. return {
  7. 'targets': ['downloaded_data/UNFCCC/submissions-bur.csv'],
  8. 'actions': ['datalad run -m "Fetch BUR submissions" '
  9. '-o downloaded_data/UNFCCC/submissions-bur.csv '
  10. './venv/bin/python code/UNFCCC_downloader/fetch_submissions_bur.py'],
  11. 'verbosity': 2,
  12. }
  13. def task_download_bur():
  14. """ Download BUR submissions """
  15. return {
  16. #'file_dep': ['downloaded_data/UNFCCC/submissions-bur.csv'],
  17. # deactivate file_dep fow now as it will always run fetch submissions
  18. # before download
  19. 'actions': ['datalad run -m "Download BUR submissions" '
  20. '-i downloaded_data/UNFCCC/submissions-bur.csv '
  21. './venv/bin/python code/UNFCCC_downloader/download_bur.py'],
  22. 'verbosity': 2,
  23. }
  24. def task_update_nc():
  25. """ Update list of NC submissions """
  26. return {
  27. 'targets': ['downloaded_data/UNFCCC/submissions-nc.csv'],
  28. 'actions': ['datalad run -m "Fetch NC submissions" '
  29. '-o downloaded_data/UNFCCC/submissions-nc.csv '
  30. './venv/bin/python code/UNFCCC_downloader/fetch_submissions_nc.py'],
  31. 'verbosity': 2,
  32. }
  33. def task_download_nc():
  34. """ Download NC submissions """
  35. return {
  36. #'file_dep': ['downloaded_data/UNFCCC/submissions-nc.csv'],
  37. # deactivate file_dep fow now as it will always run fetch submissions
  38. # before download
  39. 'actions': ['datalad run -m "Download NC submissions" '
  40. '-i downloaded_data/UNFCCC/submissions-nc.csv '
  41. './venv/bin/python code/UNFCCC_downloader/download_nc.py'],
  42. 'verbosity': 2,
  43. }
  44. def task_download_ndc():
  45. """ Download NDC submissions """
  46. return {
  47. 'actions': ['datalad run -m "Download NDC submissions" '
  48. './venv/bin/python code/UNFCCC_downloader/download_ndc.py'],
  49. 'verbosity': 2,
  50. }
  51. # read UNFCCC submissions.
  52. # datalad run is called from within the read_UNFCCC_submission.py script
  53. # add parameters and pass them to script
  54. read_config = {
  55. "country": get_var('country', None),
  56. "submission": get_var('submission', None),
  57. }
  58. def task_read_unfccc_submission():
  59. """ Read submission for a country (if code exists) """
  60. return {
  61. 'actions': [f"./venv/bin/python code/UNFCCC_reader/read_UNFCCC_submission.py "
  62. f"--country={read_config['country']} --submission={read_config['submission']}"],
  63. 'verbosity': 2,
  64. 'params': [{'name': 'country',
  65. 'short': 'c',
  66. 'long': 'country',
  67. 'default': None,
  68. 'help': 'name or ISO 3-letter code of the country to read data for (e.g. China)',
  69. 'type': str,
  70. },
  71. {'name': 'submission',
  72. 'short': 's',
  73. 'long': 'submission',
  74. 'default': None,
  75. 'help': 'submission to read (e.g. BUR4)',
  76. 'type': str,
  77. },
  78. ],
  79. }
  80. def task_country_info():
  81. """ Print information on submissions and datasets
  82. available for given country"""
  83. return {
  84. 'actions': [f"./venv/bin/python code/UNFCCC_reader/country_info.py "
  85. f"--country={read_config['country']}"],
  86. 'verbosity': 2,
  87. }