DVC | Permission denied ERROR: failed to reproduce stage: failed to run: .py, exited with 126

Viewed 77

Goal: run .py files via. dvc.yaml.

There are stages before it, in dvc.yaml, that don't produce the error.

dvc exp run:

(venv) me@ubuntu-pcs:~/PycharmProjects/project$ dvc exp run
Stage 'inference' didn't change, skipping
Running stage 'load_data':
> load_data.py
/bin/bash: line 1: load_data.py: Permission denied
ERROR: failed to reproduce 'load_data': failed to run: load_data.py, exited with 126

dvc repro:

(venv) me@ubuntu-pcs:~/PycharmProjects/project$ dvc repro
Stage 'predict' didn't change, skipping                                                                                                                                                                                                                        
Stage 'evaluate' didn't change, skipping
Stage 'inference' didn't change, skipping
Running stage 'load_data':
> load_data.py
/bin/bash: line 1: load_data.py: Permission denied
ERROR: failed to reproduce 'load_data': failed to run: pdl1_lung_model/load_data.py, exited with 126

dvc doctor:

DVC version: 2.10.2 (pip)
---------------------------------
Platform: Python 3.9.12 on Linux-5.15.0-46-generic-x86_64-with-glibc2.35
Supports:
        webhdfs (fsspec = 2022.5.0),
        http (aiohttp = 3.8.1, aiohttp-retry = 2.5.2),
        https (aiohttp = 3.8.1, aiohttp-retry = 2.5.2),
        s3 (s3fs = 2022.5.0, boto3 = 1.21.21)
Cache types: hardlink, symlink
Cache directory: ext4 on /dev/nvme0n1p5
Caches: local
Remotes: s3
Workspace directory: ext4 on /dev/nvme0n1p5
Repo: dvc, git

dvc exp run -v:

output.txt

dvc exp run -vv:

output2.txt

1 Answers

Solution 1

.py files weren't running as scripts.

They need to be; if you want to run one .py file per stage in dvc.yaml.

To do so, you want to append Boiler-plate code, at the bottom of each .py file.

if __name__ == "__main__":
    # invoke primary function() in .py file, w/ params

Solution 2

chmod 777 ....py

Soution 3

I forgot the python in cmd:

  load_data:
    cmd: python pdl1_lung_model/load_data.py
Related