Properly handle relative paths for schema imports
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Inizia in eido/schema.py, in read_schema, usando l'esempio collegato e i relativi imports come riproduzione. Esegui i comandi conda e Snakemake forniti per osservare la risoluzione della directory di lavoro corrente. Il risultato è raggiunto quando gli imports relativi vengono risolti dallo schema che esegue l'importazione, se il relativo percorso è noto, mantenendo la directory di lavoro corrente come fallback.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Currently, as far as I can tell, relative paths in the import field of a PEP schema get resolved relative to the current working dir via the use of os.abspath in peppy (https://github.com/pepkit/peppy/blob/60523c51cc7243680797f681a9d49a1ecec3c6ca/peppy/utils.py#L154). However, my assumption as a developer using the PEPkit would be that resolution of relative paths in the import field are relative to the location of the PEP schema which imports upstream schemas (the "importing schema").
The current working dir being used for relative path resolution is an issue when the (pipleine) developer writing the PEP schema has no control over what the current working directory is in relation to the importing schema, as is the case for Snakemake PEP schemas. Here, the working directory is specified by the user running the Snakemake pipeline (through specifying the output dir), while the pipeline developer might like to specify a common base schema for all their workflows (e.g. via a git submodule relative to the pipeline's schema). In this case, Eido cannot correctly resolve the path to the imported base schema in the pipeline's PEP schema (except in the special case that the output directory the pipeline user specified happens to the same as the location of the pipeline's PEP schema, which is likely not the cases most of the time). Therefore, relative paths currently cannot be used in the import field of a PEP schema without also restricting the working directory at the time the schema is constructed.
As a solution, I would propose that when another schema is imported and the import field contains a relative path, that that path is simply appended to the path of the importing schema, if the current schema is identifiable by a path. Otherwise the current working directory may still be used, if applicable. All of this should be possible to implement in the read_schema function.
Example
Project structure:
- project_root
- workflow
- Snakefile
- schemas
- pep_validation.yaml
- common
- schemas
- common_pep_validation.yaml
Contents of workflow/schemas/pep_validation.yaml:
[...]
imports:
- "../../common/schemas/common_pep_validation.yaml"
[...]
Contents of workflow/Snakefile:
[...]
pepschema: "schemas/validation.yaml"
[...]
This will lead to an error that Eido cannot find [working dir]../../common/schemas/common_pep_validation.yaml whenever working_dir is not set to anything nested two levels below the workflow dir. In this example working dir is set via snakemake --directory working_dir, i.e., the Snakemake pipeline's output directory.
For interactive use, I have fleshed out the example and attached it:
import_relative_path_demo.tar.gz
Set up the env via conda with the following command
conda env create --prefix ./test_env --file environment.yaml
and run
conda run --prefix test_env/ snakemake -n --config pep_config=./pep/config.yaml
and it should complain about not finding the common config file, while
conda run -p test_env/ snakemake -n --config pep_config=../../pep/config.yaml --directory workflow/test_output/
should succeed on account of the output dir being nested in the same way as the pipeline specific schema.
- Lingua principale
- Python
- Stelle
- 5
- Fork
- 6
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pepkit/eido
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
-
Improve Error-MessagesApertalikely-solved
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
-
Handling errorsForse di nuovo libera @nsheff l’ha presa 1272 giorni fa e non c’è nessuna pull request aperta. Apertaquestion
Issue simili
-
docs(contributing): the two things that silently block a PRForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaavailable documentation good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 95/100
Nixitov/Riptide-Native#944 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
JTHCode/secretguard#24 ·
I maintainer di solito rispondono entro 1 giorno
-
area: middleware documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
omarelshamy25x/shamy-hijri#63 ·
I maintainer di solito rispondono entro 1 giorno