[v2.1.3] Path should be absolute in order to guarantee a single call.

60 views
Skip to first unread message

shreedha...@gmail.com

unread,
Oct 14, 2018, 11:29:31 PM10/14/18
to Beancount
Hi, 

In beancount version 2.1.3, bean-identify (and bean-extract) now needs the input directory to be specified with it's full absolute path, or else it gives an error:


$ bean-identify  config.py input/
**** input/History.csv
Traceback (most recent call last):
 
File "/usr/local/bin/bean-identify", line 4, in <module>
   
from beancount.ingest.identify import main; main()
 
File "/usr/local/lib/python3.7/site-packages/beancount/ingest/identify.py", line 104, in main
   
return scripts_utils.trampoline_to_ingest(sys.modules[__name__])
 
File "/usr/local/lib/python3.7/site-packages/beancount/ingest/scripts_utils.py", line 132, in trampoline_to_ingest
   
return run_import_script_and_ingest(parser)
 
File "/usr/local/lib/python3.7/site-packages/beancount/ingest/scripts_utils.py", line 202, in run_import_script_and_ingest
   
return ingest(importers_list, abs_downloads)
 
File "/usr/local/lib/python3.7/site-packages/beancount/ingest/scripts_utils.py", line 102, in ingest
    args
.command(args, parser, importers_list, args.downloads)
 
File "/usr/local/lib/python3.7/site-packages/beancount/ingest/identify.py", line 100, in run
   
return identify(importers_list, files_or_directories)
 
File "/usr/local/lib/python3.7/site-packages/beancount/ingest/identify.py", line 83, in identify
    logfile
=logfile):
 
File "/usr/local/lib/python3.7/site-packages/beancount/ingest/identify.py", line 60, in find_imports
    file
= cache.get_file(filename)
 
File "/usr/local/lib/python3.7/site-packages/beancount/ingest/cache.py", line 132, in get_file
   
"Path should be absolute in order to guarantee a single call.")
AssertionError: Path should be absolute in order to guarantee a single call.

This issue is not present in beancount version 2.1.2.

I feel like the bug stems from recent changes in this commit. The full path is compute in scripts_utils.py:202, but then is replaced in the final call in scripts_utils.py:102 by args.download which doesn't have the full path. (Also strangely the function at line 102, expects its second argument as "detect_duplicates_func", and not a string (or list of strings) with file path(s)). Anyway, I hope this helps diagnose it.

I'm not sure of the complexity of the fix, though. A work around is to call the scripts like follows:

$ bean-identify  config.py $(pwd)/input/


Thanks,
Shreedhar

Zhuoyun Wei

unread,
Oct 17, 2018, 4:02:16 AM10/17/18
to bean...@googlegroups.com
I encountered this as well.

Prepending $(pwd) to the shell call does solve the problem but renders
shell auto-completion useless.

For now, I just added "filename = os.path.abspath(filename)" to the
assert statement where the exception raises.


2018-10-14 20:29:31 shreedha...@gmail.com <shreedha...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> beancount+...@googlegroups.com.
> To post to this group, send email to bean...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/
> 709141d5-88a4-444a-acef-94bf43a9b388%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
Zhuoyun Wei
signature.asc

Martin Blais

unread,
Oct 26, 2018, 12:33:53 AM10/26/18
to bean...@googlegroups.com
Thanks for the nicely reported bug guys.

1. This was indeed a bug and has been introduced indeed in that CL. I was able to reproduce it.
2. The ingest() call was indeed incorrect, though the second value is interpreted as a boolean and that was okay. 
3. I also noticed that the duplicated_detect_func people had been asking about isn't being called. I guess it wasn't that desired...

I added unit tests (which I should have done in the first place).

Thank you for the detail,




Reply all
Reply to author
Forward
0 new messages