OpenRiskNet / home

OpenRiskNet wiki and core resources
14 stars 9 forks source link

Jupyter PDF export not working #10

Closed egonw closed 4 years ago

egonw commented 6 years ago

.. bc pandoc is not installed.

Reproduce by making a simple python 3 notebook and selecting Export as PDF.

GrahamDumpleton commented 6 years ago

Installation of pandoc requires a docker build phase to install since need to use system package.

Have done this before like:

        {
            "kind": "ImageStream",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}-nb-s2i",
                "labels": {
                    "app": "${APPLICATION_NAME}"
                }
            }
        },
        {
            "kind": "BuildConfig",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}-nb-s2i",
                "labels": {
                    "app": "${APPLICATION_NAME}"
                }
            },
            "spec": {
                "triggers": [
                    {
                        "type": "ConfigChange"
                    },
                    {
                        "type": "ImageChange"
                    }
                ],
                "source": {
                    "type": "Git",
                    "git": {
                        "uri": "https://github.com/jupyter-on-openshift/jupyter-notebooks.git",
                        "ref": "1.0.1"
                    },
                    "contextDir": "minimal-notebook"
                },
                "strategy": {
                    "type": "Source",
                    "sourceStrategy": {
                        "from": {
                            "kind": "ImageStreamTag",
                            "name": "${PYTHON_IMAGE_NAME}",
                            "namespace": "openshift"
                        },
                        "env": [
                            {
                                "name": "UPGRADE_PIP_TO_LATEST",
                                "value": "true"
                            },
                            {
                                "name": "JUPYTER_INSTALL_LAB",
                                "value": "${JUPYTERHUB_ENABLE_LAB}"
                            }
                        ]
                    }
                },
                "output": {
                    "to": {
                        "kind": "ImageStreamTag",
                        "name": "${APPLICATION_NAME}-nb-s2i:latest"
                    }
                },
                "resources": {
                    "limits": {
                        "memory": "3Gi"
                    }
                }
            }
        },
        {
            "kind": "ImageStream",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}-nb-bld",
                "labels": {
                    "app": "${APPLICATION_NAME}"
                }
            }
        },
        {
            "kind": "BuildConfig",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}-nb-bld",
                "labels": {
                    "app": "${APPLICATION_NAME}"
                }
            },
            "spec": {
                "triggers": [
                    {
                        "type": "ConfigChange"
                    },
                    {
                        "type": "ImageChange"
                    }
                ],
                "source": {
                    "type": "Git",
                    "git": {
                        "uri": "https://github.com/jupyter-on-openshift/poc-hub-singapore-ntu.git"
                    },
                    "contextDir": "notebook"
                },
                "strategy": {
                    "type": "Docker",
                    "dockerStrategy": {
                        "from": {
                            "kind": "ImageStreamTag",
                            "name": "${APPLICATION_NAME}-nb-s2i:latest"
                        }
                    }
                },
                "output": {
                    "to": {
                        "kind": "ImageStreamTag",
                        "name": "${APPLICATION_NAME}-nb-bld:latest"
                    }
                },
                "resources": {
                    "limits": {
                        "memory": "3Gi"
                    }
                }
            }
        },
        {
            "kind": "ImageStream",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}-nb-img",
                "labels": {
                    "app": "${APPLICATION_NAME}"
                }
            }
        },
        {
            "kind": "BuildConfig",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}-nb-img",
                "labels": {
                    "app": "${APPLICATION_NAME}"
                }
            },
            "spec": {
                "triggers": [
                    {
                        "type": "ConfigChange"
                    },
                    {
                        "type": "ImageChange"
                    }
                ],
                "source": {
                    "type": "Git",
                    "git": {
                        "uri": "${NOTEBOOK_REPOSITORY_URL}",
                        "ref": "${NOTEBOOK_REPOSITORY_REFERENCE}"
                    },
                    "contextDir": "${NOTEBOOK_REPOSITORY_CONTEXT_DIR}"
                },
                "strategy": {
                    "type": "Source",
                    "sourceStrategy": {
                        "from": {
                            "kind": "ImageStreamTag",
                            "name": "${APPLICATION_NAME}-nb-bld:latest"
                        },
                        "env": [
                            {
                                "name": "JUPYTER_MASTER_FILES",
                                "value": "/opt/app-root/master"
                            }
                        ]
                    }
                },
                "output": {
                    "to": {
                        "kind": "ImageStreamTag",
                        "name": "${APPLICATION_NAME}-nb-img:latest"
                    }
                },
                "resources": {
                    "limits": {
                        "memory": "3Gi"
                    }
                }
            }
        }

The repo for the docker build phase can then install extra system packages from the Dockerfile.

I know a long time ago I was installing pandoc when building my own images using docker on CentOS images. I can't remember if had issues. Probably more a case I didn't know what it was in there for. Either way, wasn't being installed when doing S2I builds as can't install extra system packages and thus why need docker build phase.

tdudgeon commented 5 years ago

I tried enabling PDF export for a notebook and it seemed to required adding a huge number of packages which make the images size much bigger. A whole lot of things like LaTex support was added. I'm not sure if there is a more lightweight approach to this.

egonw commented 4 years ago

Okay, so not a bug, but a feature.