Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

simplified_api.py 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. from copy import deepcopy
  2. from .constraints import (
  3. EnsureDatasetSiblingName,
  4. EnsureExistingDirectory,
  5. )
  6. # each item is a command that is allowed in the API
  7. # the key is the command name in the Python API.
  8. # the values are dicts with the following keys
  9. # - exclude_parameters: set with parameter names to
  10. # exclude from the API
  11. api = dict(
  12. clone=dict(
  13. name='&Clone a dataset',
  14. exclude_parameters=set((
  15. 'git_clone_opts',
  16. 'reckless',
  17. 'description',
  18. )),
  19. parameter_display_names=dict(
  20. source='Clone from',
  21. path='Clone into',
  22. dataset='Register in superdataset',
  23. ),
  24. parameter_order=dict(
  25. source=0,
  26. path=1,
  27. dataset=2,
  28. ),
  29. parameter_constraints=dict(
  30. path=EnsureExistingDirectory(),
  31. ),
  32. ),
  33. create=dict(
  34. name='C&reate a dataset',
  35. exclude_parameters=set((
  36. 'initopts',
  37. 'description',
  38. 'fake_dates',
  39. )),
  40. parameter_display_names=dict(
  41. force='OK if target directory not empty',
  42. path='Create at',
  43. dataset='Register in superdataset',
  44. ),
  45. parameter_order=dict(
  46. path=0,
  47. annex=1,
  48. dataset=2,
  49. ),
  50. parameter_constraints=dict(
  51. path=EnsureExistingDirectory(),
  52. ),
  53. ),
  54. create_sibling_gitlab=dict(
  55. name='Create a Git&Lab sibling',
  56. exclude_parameters=set((
  57. 'dryrun',
  58. )),
  59. ),
  60. create_sibling_gin=dict(
  61. name='Create a GI&N sibling',
  62. exclude_parameters=set((
  63. 'dryrun',
  64. 'api'
  65. )),
  66. parameter_display_names=dict(
  67. dataset='Dataset',
  68. reponame='New repository name on Gin',
  69. name='Sibling name',
  70. private='Make Gin repo private',
  71. existing='If the sibling exists already...',
  72. recursive='Create siblings for subdatasets',
  73. credential='Name of credential to be used',
  74. access_protocol='Access protocol',
  75. publish_depends='Add publication dependency to'
  76. ),
  77. parameter_order=dict(
  78. dataset=0,
  79. reponame=1,
  80. private=2,
  81. name=3,
  82. access_protocol=4,
  83. existing=5,
  84. recursive=6,
  85. credential=7,
  86. ),
  87. ),
  88. create_sibling_github=dict(
  89. name='Create a Git&Hub sibling',
  90. exclude_parameters=set((
  91. 'dryrun',
  92. 'github_login',
  93. 'github_organization',
  94. 'api'
  95. )),
  96. parameter_display_names=dict(
  97. dataset='Dataset',
  98. reponame='New repository name on Github',
  99. name='Sibling name',
  100. private='Make GitHub repo private',
  101. existing='If the sibling exists already...',
  102. recursive='Create siblings for subdatasets',
  103. credential='Name of credential to be used',
  104. access_protocol='Access protocol',
  105. publish_depends='Add publication dependency to'
  106. ),
  107. parameter_order=dict(
  108. dataset=0,
  109. reponame=1,
  110. private=2,
  111. name=3,
  112. access_protocol=4,
  113. existing=5,
  114. recursive=6,
  115. credential=7,
  116. ),
  117. ),
  118. create_sibling_webdav=dict(
  119. name='Create a &WebDAV sibling',
  120. ),
  121. drop=dict(
  122. name='Dr&op content',
  123. exclude_parameters=set((
  124. 'check',
  125. 'if_dirty',
  126. 'reckless',
  127. )),
  128. parameter_display_names=dict(
  129. dataset='Drop from dataset at',
  130. what='What to drop',
  131. path='Only drop',
  132. recursive='Also drop (in) any subdatasets',
  133. ),
  134. parameter_order=dict(
  135. dataset=0,
  136. what=1,
  137. path=2,
  138. recursive=3,
  139. ),
  140. ),
  141. get=dict(
  142. name='&Get content',
  143. exclude_parameters=set((
  144. 'description',
  145. 'reckless',
  146. 'source',
  147. )),
  148. parameter_display_names=dict(
  149. path='Only get',
  150. # 'all' because we have no recursion_limit enabled
  151. recursive='Also get all subdatasets',
  152. get_data='Get file content',
  153. ),
  154. parameter_order=dict(
  155. dataset=0,
  156. get_data=1,
  157. path=2,
  158. recursive=3,
  159. ),
  160. ),
  161. push=dict(
  162. name='&Push data/updates to a sibling',
  163. exclude_parameters=set((
  164. 'since',
  165. )),
  166. parameter_constraints=dict(
  167. to=EnsureDatasetSiblingName(),
  168. ),
  169. parameter_display_names=dict(
  170. dataset='Push from dataset at',
  171. to='To dataset sibling',
  172. data='What to push',
  173. path='Limit to',
  174. force='Force operation',
  175. ),
  176. parameter_order=dict(
  177. dataset=0,
  178. to=1,
  179. data=2,
  180. path=3,
  181. recursive=4,
  182. ),
  183. ),
  184. save=dict(
  185. name='&Save the state in a dataset',
  186. exclude_parameters=set((
  187. 'updated',
  188. 'message_file',
  189. )),
  190. parameter_display_names=dict(
  191. dataset='Save changes in dataset at',
  192. message='Description of change',
  193. path='Only save',
  194. recursive='Include changes in subdatasets',
  195. to_git='Do not put files in annex',
  196. version_tag='Tag for saved dataset state',
  197. amend='Amend last saved state',
  198. ),
  199. parameter_order=dict(
  200. dataset=0,
  201. message=1,
  202. path=2,
  203. recursive=3,
  204. to_git=4,
  205. version_tag=5,
  206. amend=6,
  207. ),
  208. ),
  209. update=dict(
  210. name='&Update from a sibling',
  211. exclude_parameters=set((
  212. 'merge',
  213. 'fetch_all',
  214. 'how_subds',
  215. 'follow',
  216. 'reobtain_data',
  217. )),
  218. parameter_constraints=dict(
  219. sibling=EnsureDatasetSiblingName(),
  220. ),
  221. ),
  222. )
  223. dataset_api = {
  224. c: s for c, s in api.items()
  225. if c in (
  226. 'clone', 'create',
  227. 'create_sibling_gitlab', 'create_sibling_gin',
  228. 'create_sibling_github', 'create_sibling_webdav',
  229. 'drop', 'get', 'push', 'save', 'update'
  230. )
  231. }
  232. directory_api = {
  233. c: s for c, s in api.items() if c in ('clone', 'create')
  234. }
  235. directory_in_ds_api = {
  236. c: s for c, s in api.items()
  237. if c in ('clone', 'create', 'drop', 'get', 'push', 'save')
  238. }
  239. file_api = None
  240. file_in_ds_api = {
  241. c: s for c, s in api.items() if c in ('save')
  242. }
  243. annexed_file_api = {}
  244. for c, s in api.items():
  245. if c not in ('drop', 'get', 'push', 'save'):
  246. continue
  247. s = deepcopy(s)
  248. # recursion underneath a file is not possible
  249. s['exclude_parameters'].add('recursive')
  250. # there can only ever be a single path
  251. s['parameter_nargs'] = dict(path=1)
  252. # path subselection does not make sense, but if we exclude it
  253. # the config dialog is practically empty. keep as some kind of
  254. # confirmation
  255. #s['exclude_parameters'].add('path')
  256. annexed_file_api[c] = s
  257. # get of a single annexed files can be simpler
  258. af_get = annexed_file_api['get']
  259. # not getting data for an annexed file makes no sense
  260. af_get['exclude_parameters'].add('get_data')
  261. gooey_suite = dict(
  262. # may contain keyboard navigation hints
  263. title='&Simplified',
  264. description='Simplified access to the most essential operations',
  265. options=dict(
  266. disable_manual_path_input=True,
  267. ),
  268. apis=dict(
  269. dataset=dataset_api,
  270. directory=directory_api,
  271. directory_in_ds=directory_in_ds_api,
  272. file=file_api,
  273. file_in_ds=file_in_ds_api,
  274. annexed_file=annexed_file_api,
  275. ),
  276. # simplified API has no groups
  277. api_group_order={},
  278. exclude_parameters=set((
  279. 'result_renderer',
  280. 'return_type',
  281. 'result_filter',
  282. 'result_xfm',
  283. 'on_failure',
  284. 'jobs',
  285. 'recursion_limit',
  286. )),
  287. parameter_display_names=dict(
  288. annex='Dataset with file annex',
  289. cfg_proc='Configuration procedure(s)',
  290. dataset='Dataset location',
  291. ),
  292. )