korymath / talk-generator

talk-generator is capable of generating coherent slide decks based on a single topic suggestion.
MIT License
124 stars 9 forks source link

KeyError Prohibited Image Not Found? #54

Closed korymath closed 4 years ago

korymath commented 5 years ago
Traceback (most recent call last):
  File "/Users/korymathewson/work/talk-generator/venv/bin/talkgenerator", line 11, in <module>
    load_entry_point('talkgenerator', 'console_scripts', 'talkgenerator')()
  File "/Users/korymathewson/work/talk-generator/talkgenerator/run.py", line 11, in main_cli
    main(args)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/run.py", line 6, in main
    presentations, slide_deck = utils.generate_talk(args)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/utils.py", line 63, in generate_talk
    parallel=args.parallel,
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/presentation_schema.py", line 68, in generate_presentation
    used_tags,
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/presentation_schema.py", line 115, in _generate_slide_deck_parallel
    slide_nrs_to_generate,
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 260, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 608, in get
    raise self._value
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/presentation_schema.py", line 347, in __call__
    prohibited_generators=self.prohibited_generators,
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/presentation_schema.py", line 228, in generate_slide
    slide_result = generator.generate(presentation_context, used_elements)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/slide_generator_data.py", line 70, in generate
    presentation_context, (used_elements, self._allowed_repeated_elements)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/slide/slide_generators.py", line 27, in generate_slide
    generated = self._slide_content_generator(presentation_context)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/slide/slide_generators.py", line 236, in __call__
    self._image_2_generator(presentation_context),
  File "/Users/korymathewson/work/talk-generator/talkgenerator/util/generator_util.py", line 24, in __call__
    generated = generator(seed)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/util/generator_util.py", line 24, in __call__
    generated = generator(seed)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/util/generator_util.py", line 193, in __call__
    generated = generator(context)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/content_generator_structures.py", line 88, in generate
    return self._generate(presentation_context)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/util/generator_util.py", line 171, in __call__
    if os_util.is_valid_image(downloaded_url):
  File "/Users/korymathewson/work/talk-generator/talkgenerator/util/os_util.py", line 84, in is_valid_image
    im = open_image(os.path.normpath(image_url))
KeyError: ('/Users/korymathewson/work/talk-generator/talkgenerator/data/prohibited_images/imgur_removed.jpg',)
twinters commented 5 years ago

Interesting! Was this during a normal slide generation run, without any special parameters?

korymath commented 5 years ago

Yes. It was the standard run call from the README, but with num_slides=25

korymath commented 5 years ago
Traceback (most recent call last):
  File "run.py", line 15, in <module>
    main(utils.get_argument_parser().parse_args())
  File "run.py", line 6, in main
    presentations, slide_deck = utils.generate_talk(args)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/utils.py", line 60, in generate_talk
    parallel=args.parallel,
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/presentation_schema.py", line 68, in generate_presentation
    used_tags,
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/presentation_schema.py", line 115, in _generate_slide_deck_parallel
    slide_nrs_to_generate,
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 260, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 608, in get
    raise self._value
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/presentation_schema.py", line 347, in __call__
    prohibited_generators=self.prohibited_generators,
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/presentation_schema.py", line 228, in generate_slide
    slide_result = generator.generate(presentation_context, used_elements)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/slide_generator_data.py", line 70, in generate
    presentation_context, (used_elements, self._allowed_repeated_elements)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/slide/slide_generators.py", line 27, in generate_slide
    generated = self._slide_content_generator(presentation_context)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/slide/slide_generators.py", line 234, in __call__
    self._image_1_generator(presentation_context),
  File "/Users/korymathewson/work/talk-generator/talkgenerator/util/generator_util.py", line 203, in __call__
    generated = generator(context)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/schema/content_generator_structures.py", line 88, in generate
    return self._generate(presentation_context)
  File "/Users/korymathewson/work/talk-generator/talkgenerator/util/generator_util.py", line 181, in __call__
    if os_util.is_valid_image(downloaded_url):
  File "/Users/korymathewson/work/talk-generator/talkgenerator/util/os_util.py", line 84, in is_valid_image
    im = open_image(os.path.normpath(image_url))
KeyError: ('/Users/korymathewson/work/talk-generator/talkgenerator/data/prohibited_images/imgur_removed_2.jpg',)

Happened again on a latest run.

Also, I am not seeing any statuses with 'Unsplash' in the logging output? Should we be?

twinters commented 5 years ago

Happened again on a latest run.

I can't seem to replicate this. Maybe it's a mac thing? I don't understand why it is calling open_image(os.path.normpath(image_url)) on these locally stored prohibited images anyway, as it should only be called on downloaded images. Is this on the latest version you're running this? I've now added some additional checks, but I'm not sure they will be able to solve this.

Also, I am not seeing any statuses with 'Unsplash' in the logging output? Should we be?

There are checks and warnings before running to see if the credentials are given. I've added an additional one in https://github.com/korymath/talk-generator/commit/115c7db83324955b9840c2762b3d78452cbb9672

twinters commented 4 years ago

Haven't had this issue in a while, even after generating hundreds of slide decks. Seems to be fixed, possibly in one of the big refactors.