Dobromir Chankov
Dobromir Chankov

Reputation: 1

I want to parametrize my pipeline.yaml file but Ploomber can not read my env.yaml file

I use poetry.It's in a directory. Then a subdirectory(named "src") were created and Ploomber worked normal in this subdirectory loading correct its files.

But when I created a second subdirectory(named "src_common") at the same level as the first one("src"), I got a problem:

My pipeline.yaml file is:

tasks:
  - source: tasks/get_papers_common.py
    product: 
      nb: output/get_papers_common.ipynb
      data: output/openalex_papers.xlsx
  - params:
      openalex_search_url: "{{openalex_search_url}}"
      openalex_filter: "{{openalex_filter}}"
      publication_year: "{{publication_year}}"
      work_type: "{{work_type}}"
      grants_award_id: "{{grants_award_id}}"
      openalex_keywords: "{{openalex_keywords}}"
      more_keywords: "{{more_keywords}}"
      sort: "{{sort}}"
      cursor: "{{cursor}}"
      RESULTS_PER_PAGE: "{{RESULTS_PER_PAGE}}"
      MAX_PAGE: "{{MAX_PAGE}}"

and my env.yaml file is:

openalex_search_url: https://api.openalex.org/works

openalex_filter: publication_year:{},type:{},grants.award_id:{},default.search:{},fulltext.search:{}

publication_year: >2000

work_type: article|review
 
grants_award_id: 310584|646221|604134|760840|686239|814426|814401|814425|760813|760928|862296|862195|862419|953183|952924|952921|964766|965196|965367|964827|965173|964766|101092164|965196|965367|964827|965173

openalex_keywords: 'surface area' AND 'nanoparticle' 

more_keywords : exposure 
      
sort: display_name:desc
      
RESULTS_PER_PAGE: 200
cursor : *
 
MAX_PAGE: 150

1. When I try:

ploomber build -e env.yaml --entry-point pipeline_common.yaml --force

I get: Traceback (most recent call last): File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\env\envdict.py", line 396, in load_from_source raw = yaml.load(f, Loader=yaml.SafeLoader) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\yaml_init_.py", line 79, in load loader = Loader(stream) ^^^^^^^^^^^^^^ File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\yaml\loader.py", line 34, in init Reader.init(self, stream) File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\yaml\reader.py", line 85, in init self.determine_encoding() File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\yaml\reader.py", line 124, in determine_encoding self.update_raw() File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\yaml\reader.py", line 178, in update_raw data = self.stream.read(size) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dobromir\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 479: character maps to

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\env\envdict.py", line 398, in load_from_source raise type(e)( ^^^^^^^^ TypeError: function takes exactly 5 arguments (1 given)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\cli\io.py", line 54, in wrapper fn(**kwargs) File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber_core\telemetry\telemetry.py", line 698, in wrapper result = func(_payload, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\cli\build.py", line 69, in main dag, args = parser.load_from_entry_point_arg() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\cli\parsers.py", line 225, in load_from_entry_point_arg dag, args = load_dag_from_entry_point_and_parser(entry_point, self, sys.argv) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\cli\parsers.py", line 503, in load_dag_from_entry_point_and_parser dag, args = _process_file_dir_or_glob(parser) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\cli\parsers.py", line 421, in _process_file_dir_or_glob env_dict = EnvDict( ^^^^^^^^ File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\env\envdict.py", line 110, in init ) = load_from_source(source) ^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\IDEA_on_D\Harmless\T775.venv\Lib\site-packages\ploomber\env\envdict.py", line 406, in load_from_source if not isinstance(raw, Mapping): ^^^ UnboundLocalError: cannot access local variable 'raw' where it is not associated with a value

2. When I try after a name change only (from env.yaml to env_common.yaml) I get:

ploomber build -e env_common.yaml --entry-point pipeline_common.yaml --force

Error: Error replacing placeholders:

Loaded env: EnvDict({'cwd': 'D:\IDEA_on_...5\src_common', 'git': 'general_two_level_search', 'git_hash': '3ee1ac2-dirty', 'here': 'D:\IDEA_on_...5\src_common', ...})

Upvotes: 0

Views: 44

Answers (0)

Related Questions