-
Notifications
You must be signed in to change notification settings - 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
Conversation
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.
A few suggestions.
qiita_client/plugin.py
Outdated
@@ -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'] |
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.
What about adding another global variable: _DEFAULT_PLUGIN_COUPLINGS = 'filesystem'
; then change this to _ALLOWED_PLUGIN_COUPLINGS = [_DEFAULT_PLUGIN_COUPLINGS, 'https']
.
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.
stupid me. Should have done this already :-) Thanks!
qiita_client/plugin.py
Outdated
@@ -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]): |
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.
then here you can replace _ALLOWED_PLUGIN_COUPLINGS[0]
for _DEFAULT_PLUGIN_COUPLINGS
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.
done
qiita_client/plugin.py
Outdated
# 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. |
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.
Should this be part of the readme in the repo? I think moving these lines there will give them more visibility for future developers; what do you think?
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.
I happily promoted this section into a new paragraph in the readme.md
qiita_client/plugin.py
Outdated
@@ -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'. |
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.
--> Valid values are _see _ALLOWED_PLUGIN_COUPLINGS
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.
done
qiita_client/plugin.py
Outdated
# 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] |
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.
_DEFAULT_PLUGIN_COUPLINGS
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.
much cleaner now.
qiita_client/qiita_client.py
Outdated
@@ -714,3 +743,116 @@ def _process_files_per_sample_fastq(self, files, prep_info, | |||
prep_info = prep_info.filter(items=sample_names.keys(), axis=0) | |||
|
|||
return sample_names, prep_info | |||
|
|||
def fetch_file_from_central(self, filepath, prefix=''): |
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.
Wondering if the default should be for prefix to be None? Maybe this is clear that it will be ignored ...
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.
agreed. I thought testing for this could be done via If not prefix:
, however, this does not seem to work with None
?! Therefore, if conditions are slightly longer now
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.
A couple of questions.
@@ -104,7 +104,8 @@ jobs: | |||
mkdir -p ${CONDA_PREFIX}/var/run/nginx/ | |||
export NGINX_FILE=`pwd`/qiita-dev/qiita_pet/nginx_example.conf | |||
export NGINX_FILE_NEW=`pwd`/qiita-dev/qiita_pet/nginx_example_local.conf | |||
sed "s#/home/runner/work/qiita/qiita#${PWD}/qiita-dev/#g" ${NGINX_FILE} > ${NGINX_FILE_NEW} | |||
sed "s#/home/runner/work/qiita/qiita#${PWD}/qiita-dev#g" ${NGINX_FILE} > ${NGINX_FILE_NEW} | |||
sed -i "s#/Users/username/qiita#${PWD}/qiita-dev#g" ${NGINX_FILE_NEW} |
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 urls
line 108 is necessary for the nginx test instance to point to the actual BASE_DATA_DIR
within the github action: https://github.com/qiita-spots/qiita/blob/a34dcebc44ea6408340d31ecaf0efd1f78e3cc6b/qiita_pet/nginx_example.conf#L57-L63
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. |
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.
This confuses me, why have the config-file and the environmental variable? I think just leaving the env var should suffice, but I might be missing something ....
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.
it CAN all be done just by the environment variable. However, qiita collects the plugin configuration files in the PLUGIN_DIR
directory. I thought it would be handy to store the protocol in these files, such that a DB reset won't hurt - which is common during testing
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.
I see what you are saying but then this will set that variable for that plugin, meaning that we might need multiple plugins for the same command based on the configuration; right? For example, deblur would need a plugin that uses filesystem and another for https; which I believe we decided it was not desirable but I also know that we are still figuring out this. What do you think?
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.
I think it is fine as is for your Slurm setup, but agree the config file and env seem a bit redundant.
In a container scenario, the config file would also live within the container and let the plugin know how to communicate with main - no need to obtain this value from the DB. Thus you can have two different container, holding the same plugin, but communicating differently (maybe interesting for long / short distances around the globe?) The DB would then just need to decide which URL to use for triggering, but doesn't need to worry about the protocol
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.
Got it - sorry that this is taking longer than expected, but just to confirm, then wouldn't the container always have the env variable set to https; thus, making the config file redundant?
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.
env variable would NOT be set by default, so container reads from config file, except you forcefully want to make the container change its behavior: in this case you can override via env variable
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.
OK, thank you.
This is the companion PR to qiita-spots/qiita#3480 where the heavy lifting is implemented to transfer files between qiita main and plugins via a) "filesystem", i.e. direct access as is or b) via "https" get and post tornado methods. In the feature we can extend by S3 or other protocols.
I want to re-use the existing
_request_retry
mechanism, but didn't know how to return the binary content in https://github.com/jlab/qiita_client/blob/c2d597647b3a22792a7dcd88408895e81d33ceb6/qiita_client/qiita_client.py#L394 without adding the new "rettype" parameter. Is there an easier way?