Closed Hugovdberg closed 4 months ago
Another weird thing (but that might be caused by the way snakemake initialises these objects) is that calling parse_auth
in StorageProviderSettings.__post_init__
shows that at that stage StorageProviderSettings.auth
is always None
, but in StorageProvider.__post_init__
the value of self.settings.auth
is the not-yet-parsed string value from the snakefile.
I think I found a piece of the puzzle, auth
is a string value that could be tagged, but for some reason when the settings are instantiated the value for all fields is dataclasses.MISSING
and therefore not parsed, according to this piece of code: https://github.com/snakemake/snakemake-interface-common/blob/00bc4cafddd0b18a237ff43807202075c2562f78/snakemake_interface_common/plugin_registry/plugin.py#L257-L264
Also, if it would be parsed with the field.metadata.parse_func
, the extract_values
function would raise an InvalidPluginException
on https://github.com/snakemake/snakemake-interface-common/blob/00bc4cafddd0b18a237ff43807202075c2562f78/snakemake_interface_common/plugin_registry/plugin.py#L239C35-L239C57 because the auth
metadata only specify a parse_func
but not an unparse_func
(https://github.com/snakemake/snakemake-storage-plugin-http/blob/1446dd486ce16da2219ba937c39e5c0339142bee/snakemake_storage_plugin_http/__init__.py#L70-L77)
Documenting my understanding of the problem here, sorry for the spamming of the thread.
As far as I can see the snakemake_storage_plugin_http.StorageProviderSettings
are only instantiated using the command line arguments, but not the settings from the Snakefile. That is why the values of all the fields are MISSING
, and indeed, specifying the auth method on the command line raises the InvalidPluginException
because the unparse_func
is not defined.
Some debugging with a modified __setattr__
on the SettingsBase
shows that the values are initially set to the default values from the __init__
method, but then once the settings are passed to the StorageProvider
the values have been changed without SettingsBase.__setattr__
being called. It turns out that snakemake
itself bluntly updates the class dictionary in snakemake.storage
, thereby circumventing any __setattr__
or __post_init__
calls.
This then leads to the conclusion that snakemake itself simply expects you to provide the initialised AuthBase
derived object in the Snakefile instead of the string that would be parsed from the command line. So that leaves the fact that the command line version of the auth option is broken due to the missing unparse_func
, but the Snakefile version works but is badly documented. It actually implies you pass the string instead of the object itself. I will update the original post and title to reflect the current status.
Opted to create a new issue instead, because this thread does not make much sense in the context of the command line issue.
The provider settings define an
auth
setting, however the string value is never parsed using theparse_auth
function, and the request then fails withAs far as I can see the parse function is only referenced in the metadata on the settings field, but never used. I still find the new plugin structure quite unclearly documented, so I'm not sure whether this metadata field was meant to be automagically used on instantiation, but currently the authentication is broken.