Unstructured-IO / unstructured-api-tools

Apache License 2.0
28 stars 10 forks source link

fix: standard import ref's accessible in api cells #156

Closed cragwolfe closed 1 year ago

cragwolfe commented 1 year ago

Before this fix, one could not import os in a # pipeline-api as the resulting FastAPI python module would then have import os defined twice. But, in the case where a# pipeline-api cell had a reference to an os module that had been imported previously in a non-# pipeline-api cell, an error occurred when converting the notebook since os had not been defined (as only # pipeline-api cells are inspected in the notebook->fastAPI route conversion, per design).

The fix is to include implied "standard" imports for os, gzip, mimetypes, and json when inferring parameters in pipeline_api during notebook-to-script conversion, but not when executing the jinja pipeline-template logic since those imports already exist at the top of the template.