microsoft / rat-sql

A relation-aware semantic parsing model from English to SQL
https://arxiv.org/abs/1911.04942
MIT License
406 stars 117 forks source link

preporcessing issue #61

Open Xuanfang1121 opened 2 years ago

Xuanfang1121 commented 2 years ago

when I run preprocessing script (python run.py preprocess experiments/spider-bert-run.jsonnet), it gives me the following error: Traceback (most recent call last): File "run.py", line 109, in main() File "run.py", line 73, in main preprocess.main(preprocess_config) File "/app/ratsql/commands/preprocess.py", line 53, in main preprocessor.preprocess() File "/app/ratsql/commands/preprocess.py", line 30, in preprocess data = registry.construct('dataset', self.config['data'][section]) File "/app/ratsql/utils/registry.py", line 32, in construct return instantiate( File "/app/ratsql/utils/registry.py", line 44, in instantiate raise ValueError(f'Unsupported kind for param {name}: {param.kind}') ValueError: Unsupported kind for param args: VAR_POSITIONAL

the base image ispytorch/pytorch:1.8.0-cuda11.1-cudnn8-devel in the Dockerfile. python == 3.8.8 Any suggestion?

ReinierKoops commented 2 years ago

I had a similar issue. This disappeared magically when I changed my version to Pytorch 1.5.1 with 10.1 cuda.

Would be interested to see if someone could update it to more recent version.

siyue-zhang commented 11 months ago

It is because the inspect.signature doesn't support your pytorch dataset version. A workaround could be modifying the registry.py file as following:

def instantiate(callable, config, unused_keys=(), **kwargs):
    merged = {**config, **kwargs}
    if 'dataset' in str(callable):
        signature = inspect.signature(callable.__init__)
    else:
        signature = inspect.signature(callable)
    for name, param in signature.parameters.items():
        if param.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.VAR_POSITIONAL):
            raise ValueError(f'Unsupported kind for param {name}: {param.kind}')

    if any(param.kind == inspect.Parameter.VAR_KEYWORD for param in signature.parameters.values()):
        return callable(**merged)

    missing = {}
    for key in list(merged.keys()):
        if key not in signature.parameters:
            if key not in unused_keys:
                missing[key] = merged[key]
            merged.pop(key)
    if missing:
        print(f'WARNING {callable}: superfluous {missing}', file=sys.stderr)
    return callable(**merged)