Meltano command can't be run from a subfolder
Problem to solve
Meltano doesn't allow running commands from a subdirectory of a meltano project:
cd transforms
meltano invoke sqlfluff:lint
`meltano invoke` must be run inside a Meltano project.
Use `meltano init <project_name>` to create one.
If you are in a project, you may be in a subfolder. Navigate to the root directory.
Given SQLFluff has an outstanding issue that requires it to be run from the root of the DBT project to use DBT as the marcro executor, we have to work around this with:
MELTANO_PROJECT_ROOT=/path/to/meltano/project meltano invoke sqlfluff:lint
Proposal
Instead, we could have Meltano recurse up from the current directory looking for a Meltano project. It seems this was a feature that used to exist in Meltano but was reverted in #510 (closed) due to threading issues.
I could be wrong here but my hunch is the problem at that time was the code was using os.chdir
to change the working directory from the perspective of Python. I've searched the code and os.chdir
no longer exists in the codebase, so I believe it's safe to restore this feature.