table.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. import click
  17. from flow_client.flow_cli.utils import cli_args
  18. from flow_client.flow_cli.utils.cli_utils import preprocess, access_server
  19. @click.group(short_help="Table Operations")
  20. @click.pass_context
  21. def table(ctx):
  22. """
  23. \b
  24. Provides numbers of table operational commands, including info and delete.
  25. For more details, please check out the help text.
  26. """
  27. pass
  28. @table.command("info", short_help="Query Table Command")
  29. @cli_args.NAMESPACE_REQUIRED
  30. @cli_args.TABLE_NAME_REQUIRED
  31. @click.pass_context
  32. def info(ctx, **kwargs):
  33. """
  34. \b
  35. - DESCRIPTION:
  36. Query Table Information.
  37. \b
  38. - USAGE:
  39. flow table info -n $NAMESPACE -t $TABLE_NAME
  40. """
  41. config_data, dsl_data = preprocess(**kwargs)
  42. access_server('post', ctx, 'table/table_info', config_data)
  43. @table.command("delete", short_help="Delete Table Command")
  44. @cli_args.NAMESPACE
  45. @cli_args.TABLE_NAME
  46. @cli_args.JOBID
  47. @cli_args.ROLE
  48. @cli_args.PARTYID
  49. @cli_args.COMPONENT_NAME
  50. @click.pass_context
  51. def delete(ctx, **kwargs):
  52. """
  53. \b
  54. - DESCRIPTION:
  55. Delete A Specified Table.
  56. \b
  57. - USAGE:
  58. flow table delete -n $NAMESPACE -t $TABLE_NAME
  59. flow table delete -j $JOB_ID -r guest -p 9999
  60. """
  61. config_data, dsl_data = preprocess(**kwargs)
  62. access_server('post', ctx, 'table/delete', config_data)
  63. @table.command("disable", short_help="Disable Table Command")
  64. @cli_args.NAMESPACE
  65. @cli_args.TABLE_NAME
  66. @click.pass_context
  67. def disable(ctx, **kwargs):
  68. """
  69. \b
  70. - DESCRIPTION:
  71. Disable A Specified Table.
  72. \b
  73. - USAGE:
  74. flow table disable -n $NAMESPACE -t $TABLE_NAME
  75. """
  76. config_data, dsl_data = preprocess(**kwargs)
  77. access_server('post', ctx, 'table/disable', config_data)
  78. @table.command("enable", short_help="Disable Table Command")
  79. @cli_args.NAMESPACE
  80. @cli_args.TABLE_NAME
  81. @click.pass_context
  82. def disable(ctx, **kwargs):
  83. """
  84. \b
  85. - DESCRIPTION:
  86. Enable A Specified Table.
  87. \b
  88. - USAGE:
  89. flow table enable -n $NAMESPACE -t $TABLE_NAME
  90. """
  91. config_data, dsl_data = preprocess(**kwargs)
  92. access_server('post', ctx, 'table/enable', config_data)
  93. @table.command("disable-delete", short_help="Delete Disable Table Command")
  94. @click.pass_context
  95. def disable(ctx, **kwargs):
  96. """
  97. \b
  98. - DESCRIPTION:
  99. Delete Disable A Specified Table.
  100. \b
  101. - USAGE:
  102. flow table disable-delete
  103. """
  104. config_data, dsl_data = preprocess(**kwargs)
  105. access_server('post', ctx, 'table/disable/delete', config_data)
  106. @table.command("add", short_help="Add Table Command")
  107. @cli_args.CONF_PATH
  108. @click.pass_context
  109. def add(ctx, **kwargs):
  110. """
  111. - DESCRIPTION:
  112. \b
  113. Add a address to fate address.
  114. Used to be 'table_add'.
  115. \b
  116. - USAGE:
  117. flow table add -c fate_flow/examples/bind_hdfs_table.json
  118. """
  119. config_data, _ = preprocess(**kwargs)
  120. access_server('post', ctx, 'table/add', config_data)
  121. @table.command("bind", short_help="Bind Table Command")
  122. @cli_args.CONF_PATH
  123. @click.option('--drop', is_flag=True, default=False,
  124. help="If specified, data of old version would be replaced by the current version. "
  125. "Otherwise, current upload task would be rejected. (default: False)")
  126. @click.pass_context
  127. def bind(ctx, **kwargs):
  128. """
  129. - DESCRIPTION:
  130. \b
  131. Bind a address to fate address.
  132. Used to be 'table_bind'.
  133. \b
  134. - USAGE:
  135. flow table bind -c fate_flow/examples/bind_hdfs_table.json
  136. """
  137. config_data, _ = preprocess(**kwargs)
  138. access_server('post', ctx, 'table/bind', config_data)
  139. @table.command("connector-create", short_help="create or update connector")
  140. @cli_args.CONF_PATH
  141. @click.pass_context
  142. def connector_create_or_update(ctx, **kwargs):
  143. """
  144. - DESCRIPTION:
  145. \b
  146. Create a connector to fate address.
  147. \b
  148. - USAGE:
  149. flow table connector-create -c fateflow/examples/connector/create_or_update.json
  150. """
  151. config_data, _ = preprocess(**kwargs)
  152. access_server('post', ctx, 'table/connector/create', config_data)
  153. @table.command("connector-query", short_help="query connector info")
  154. @cli_args.CONNECTOR_NAME
  155. @click.pass_context
  156. def connector_query(ctx, **kwargs):
  157. """
  158. - DESCRIPTION:
  159. \b
  160. query connector info.
  161. \b
  162. - USAGE:
  163. flow table connector-query --connector-name xxx
  164. """
  165. config_data, _ = preprocess(**kwargs)
  166. access_server('post', ctx, 'table/connector/query', config_data)
  167. @table.command("tracking-source", short_help="Tracking Source Table")
  168. @cli_args.NAMESPACE
  169. @cli_args.TABLE_NAME
  170. @click.pass_context
  171. def tracking_source(ctx, **kwargs):
  172. """
  173. - DESCRIPTION:
  174. \b
  175. tracking a table's parent table
  176. \b
  177. - USAGE:
  178. flow table tracking_source -n $NAMESPACE -t $TABLE_NAME
  179. """
  180. config_data, _ = preprocess(**kwargs)
  181. access_server('post', ctx, 'table/tracking/source', config_data)
  182. @table.command("tracking-job", short_help="Tracking Using Table Job")
  183. @cli_args.NAMESPACE
  184. @cli_args.TABLE_NAME
  185. @click.pass_context
  186. def tracking_job(ctx, **kwargs):
  187. """
  188. - DESCRIPTION:
  189. \b
  190. tracking jobs of using table
  191. \b
  192. - USAGE:
  193. flow table tracking_job -n $NAMESPACE -t $TABLE_NAME
  194. """
  195. config_data, _ = preprocess(**kwargs)
  196. access_server('post', ctx, 'table/tracking/job', config_data)