Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Execute altair_saver with user apache #68

Closed
steevensmelo opened this issue May 7, 2020 · 5 comments
Closed

Execute altair_saver with user apache #68

steevensmelo opened this issue May 7, 2020 · 5 comments

Comments

@steevensmelo
Copy link

Hi, thank you very much for this amazing library.

I have a problem when I execute this line with user apache in my application in a docker container.

chart.save('chart.png', scale_factor=2.0)

I obtain this error:

ValueError: No enabled saver found that supports format='png'

I am using chromedriver and chromium package, I was search in the code and I find a possible reason, in this lines of the file altair_saver/savers/_selenium.py is added a header only for user root.

        # For linux/osx root user with Chrome, need to add --no-sandbox option, which
        # must come before the --headless option. Note: geteuid doesn't exist on windows.
        if (
            issubclass(webdriver_class, selenium.webdriver.Chrome)
            and hasattr(os, "geteuid")
            and os.geteuid() == 0
        ):
            webdriver_options.add_argument("--no-sandbox")

I change the code of the file and added this header for all user and my application works without problems.

Its posible remove this validation only for root user and added the header for all users?

Thanks a lot.

@jakevdp
Copy link
Member

jakevdp commented May 7, 2020

I don't think it's appropriate to use no-sandbox in all cases, but it may be worthwhile to add the ability to configure the default. Would you like to submit a PR to enable that?

@steevensmelo
Copy link
Author

steevensmelo commented May 8, 2020

Thank you for reply.

Yes, of course. But basically I commented all lines and I added the argument "no-sandox" in the web driver options.

        # For linux/osx root user with Chrome, need to add --no-sandbox option, which
        # must come before the --headless option. Note: geteuid doesn't exist on windows.
        """if (
            issubclass(webdriver_class, selenium.webdriver.Chrome)
            and hasattr(os, "geteuid")
            and os.geteuid() == 0
        ):
            webdriver_options.add_argument("--no-sandbox")"""

        webdriver_options.add_argument("--no-sandbox")
        webdriver_options.add_argument("--headless")

        driver_obj = webdriver_class(options=webdriver_options)
        atexit.register(driver_obj.quit)
        driver_obj.set_page_load_timeout(driver_timeout)
        self.drivers[webdriver] = driver_obj

        return driver_obj

Can you explain how to can change the default configurations?

@jakevdp
Copy link
Member

jakevdp commented May 8, 2020

What I mean is that we could add an argument to the relevant Python functions to allow the user to specify driver flags that they would like to be used.

The other option that does not involve any modification of the source code is that you could instantiate the driver that you want to use and pass it via the webdriver argument.

@steevensmelo
Copy link
Author

Hello,

Have you been able to review anything?

Thanks a lot.

@joelostblom
Copy link
Member

Since Altair 5.2, the functionality of Altair Saver is now available in Altair via the vl-convert package. Most of the functionality has been available since 5.0, and the main addition in 5.2 was PDF export. See the docs on how to save charts for more details.

We are going to archive this repo, so I'm closing all the open issues and PRs before doing so. Try out the new options for saving charts mentioned above and if you run into issues, please open an issue directly in the altair or vl-convert repo.

@joelostblom joelostblom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants