-
Couldn't load subscription status.
- Fork 7
Client: Separate plugin file system #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 26 commits
461f69f
fefc02b
a04beeb
8f9fbec
8d0844d
47a4551
8d22021
e032053
7d5b098
349ab44
1fdf1e5
748f727
8f26804
509b3d5
0cc6a50
738ab79
0849ca7
e1cb5b6
ba929a2
1d26830
85c40f2
7c46442
d9543c9
b9ade44
e336fbc
c2d5976
65e6f48
7b6ca63
296e32c
384e97d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,13 +136,46 @@ def __init__(self, name, description, can_be_submitted_to_ebi, | |
|
|
||
|
|
||
| class BaseQiitaPlugin(object): | ||
| def __init__(self, name, version, description, publications=None): | ||
| # default must be first element | ||
| _ALLOWED_PLUGIN_COUPLINGS = ['filesystem', 'https'] | ||
|
||
|
|
||
| def __init__(self, name, version, description, publications=None, | ||
| plugincoupling=_ALLOWED_PLUGIN_COUPLINGS[0]): | ||
| logger.debug('Entered BaseQiitaPlugin.__init__()') | ||
| self.name = name | ||
| self.version = version | ||
| self.description = description | ||
| self.publications = dumps(publications) if publications else "" | ||
|
|
||
| # Depending on your compute architecture, there are multiple options | ||
| # available how "thight" plugins are coupled to the central | ||
| # Qiita master/workers | ||
| # --- filesystem --- | ||
| # The default scenario is "filesystem", i.e. plugins as well as | ||
| # master/worker have unrestricted direct access to a shared filesystem, | ||
| # e.g. a larger volume / directory, defined in the server configuration | ||
| # as base_data_dir | ||
| # --- https --- | ||
| # A second scenario is that your plugins execute as independent jobs on | ||
| # another machine, e.g. as docker containers or other cloud techniques. | ||
| # Intentionally, you don't want to use a shared filesystem, but you | ||
| # have to make sure necessary input files are provided to the | ||
| # containerized plugin before execution and resulting files are | ||
| # transfered back to the central Qiita master/worker. In this case, | ||
| # files are pulled / pushed through functions | ||
| # qiita_client.fetch_file_from_central and | ||
| # qiita_client.push_file_to_central, respectivey. | ||
| # Actually, all files need to be decorated with this function. | ||
| # The decision how data are transferred is then made within these two | ||
| # functions according to the "plugincoupling" setting. | ||
| if plugincoupling not in self._ALLOWED_PLUGIN_COUPLINGS: | ||
| raise ValueError( | ||
| ("valid plugincoupling values are ['%s'], but you " | ||
| "provided %s") % ( | ||
| "', '".join(self._ALLOWED_PLUGIN_COUPLINGS), | ||
| plugincoupling)) | ||
| self.plugincoupling = plugincoupling | ||
|
|
||
| # Will hold the different commands | ||
| self.task_dict = {} | ||
|
|
||
|
|
@@ -151,7 +184,8 @@ def __init__(self, name, version, description, publications=None): | |
| 'QIITA_PLUGINS_DIR', join(expanduser('~'), '.qiita_plugins')) | ||
| self.conf_fp = join(conf_dir, "%s_%s.conf" % (self.name, self.version)) | ||
|
|
||
| def generate_config(self, env_script, start_script, server_cert=None): | ||
| def generate_config(self, env_script, start_script, server_cert=None, | ||
| plugin_coupling=_ALLOWED_PLUGIN_COUPLINGS[0]): | ||
|
||
| """Generates the plugin configuration file | ||
|
|
||
| Parameters | ||
|
|
@@ -165,6 +199,9 @@ def generate_config(self, env_script, start_script, server_cert=None): | |
| If the Qiita server used does not have a valid certificate, the | ||
| path to the Qiita certificate so the plugin can connect over | ||
| HTTPS to it | ||
| plugin_coupling : str | ||
| Type of coupling of plugin to central for file exchange. | ||
| Valid values are 'filesystem' and 'https'. | ||
|
||
| """ | ||
| logger.debug('Entered BaseQiitaPlugin.generate_config()') | ||
| sr = SystemRandom() | ||
|
|
@@ -178,7 +215,8 @@ def generate_config(self, env_script, start_script, server_cert=None): | |
| f.write(CONF_TEMPLATE % (self.name, self.version, self.description, | ||
| env_script, start_script, | ||
| self._plugin_type, self.publications, | ||
| server_cert, client_id, client_secret)) | ||
| server_cert, client_id, client_secret, | ||
| plugin_coupling)) | ||
|
|
||
| def _register_command(self, command): | ||
| """Registers a command in the plugin | ||
|
|
@@ -188,8 +226,8 @@ def _register_command(self, command): | |
| command: QiitaCommand | ||
| The command to be added to the plugin | ||
| """ | ||
| logger.debug( | ||
| f'Entered BaseQiitaPlugin._register_command({command.name})') | ||
| logger.debug('Entered BaseQiitaPlugin._register_command(%s)' % | ||
| command.name) | ||
| self.task_dict[command.name] = command | ||
|
|
||
| def _register(self, qclient): | ||
|
|
@@ -244,14 +282,33 @@ def __call__(self, server_url, job_id, output_dir): | |
| with open(self.conf_fp, 'U') as conf_file: | ||
| config.readfp(conf_file) | ||
|
|
||
| # the plugin coupling protocoll can be set in three ways | ||
| # 1. default is always "filesystem", i.e. first value in | ||
| # _ALLOWED_PLUGIN_COUPLINGS. This is to be downward compatible. | ||
| # 2. the plugin configuration can hold a section 'network' with an | ||
| # option 'PLUGINCOUPLING'. For old config files, this might not | ||
| # (yet) be the case. Therefore, we are double checking existance | ||
| # of this section and parameter here. | ||
| # 3. you can set the environment variable QIITA_PLUGINCOUPLING | ||
| # Precedence is 3, 2, 1, i.e. the environment variable overrides the | ||
| # other two ways. | ||
|
||
| plugincoupling = self._ALLOWED_PLUGIN_COUPLINGS[0] | ||
|
||
| if config.has_section('network') and \ | ||
| config.has_option('network', 'PLUGINCOUPLING'): | ||
| plugincoupling = config.get('network', 'PLUGINCOUPLING') | ||
| if 'QIITA_PLUGINCOUPLING' in environ.keys() and \ | ||
| environ['QIITA_PLUGINCOUPLING'] is not None: | ||
| plugincoupling = environ['QIITA_PLUGINCOUPLING'] | ||
|
|
||
| qclient = QiitaClient(server_url, config.get('oauth2', 'CLIENT_ID'), | ||
| config.get('oauth2', 'CLIENT_SECRET'), | ||
| # for this group of tests, confirm optional | ||
| # ca_cert parameter works as intended. Setting | ||
| # this value will prevent underlying libraries | ||
| # from validating the server's cert using | ||
| # certifi's pem cache. | ||
| ca_cert=config.get('oauth2', 'SERVER_CERT')) | ||
| ca_cert=config.get('oauth2', 'SERVER_CERT'), | ||
| plugincoupling=plugincoupling) | ||
|
|
||
| if job_id == 'register': | ||
| self._register(qclient) | ||
|
|
@@ -314,9 +371,11 @@ class QiitaTypePlugin(BaseQiitaPlugin): | |
| _plugin_type = "artifact definition" | ||
|
|
||
| def __init__(self, name, version, description, validate_func, | ||
| html_generator_func, artifact_types, publications=None): | ||
| html_generator_func, artifact_types, publications=None, | ||
| plugincoupling=BaseQiitaPlugin._ALLOWED_PLUGIN_COUPLINGS[0]): | ||
| super(QiitaTypePlugin, self).__init__(name, version, description, | ||
| publications=publications) | ||
| publications=publications, | ||
| plugincoupling=plugincoupling) | ||
|
|
||
| logger.debug('Entered QiitaTypePlugin.__init__()') | ||
| self.artifact_types = artifact_types | ||
|
|
@@ -382,4 +441,8 @@ def register_command(self, command): | |
| [oauth2] | ||
| SERVER_CERT = %s | ||
| CLIENT_ID = %s | ||
| CLIENT_SECRET = %s""" | ||
| CLIENT_SECRET = %s | ||
|
|
||
| [network] | ||
| PLUGINCOUPLING = %s | ||
| """ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this like required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 107 is to removed
//from some of the urlsline 108 is necessary for the nginx test instance to point to the actual
BASE_DATA_DIRwithin the github action: https://github.com/qiita-spots/qiita/blob/a34dcebc44ea6408340d31ecaf0efd1f78e3cc6b/qiita_pet/nginx_example.conf#L57-L63