orca icon indicating copy to clipboard operation
orca copied to clipboard

Docker: Connection refused

Open fthalabi opened this issue 5 years ago • 12 comments

Hi, I'am unable to write images using the docker image of orca.

To reproduce the problem:

import time
import plotly.io as pio
import plotly.graph_objects as go
plotly.io.orca.ensure_server()
time.sleep(30)
fig = go.Figure(
    data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],
    layout=go.Layout(
         title=go.layout.Title(text="A Bar Chart")
    )
)
fig.write_image("test.pdf")

The error:

---------------------------------------------------------------------------
ConnectionRefusedError                    Traceback (most recent call last)
/usr/lib64/python3.6/site-packages/urllib3/connection.py in _new_conn(self)
    158             conn = connection.create_connection(
--> 159                 (self._dns_host, self.port), self.timeout, **extra_kw)
    160

/usr/lib64/python3.6/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     79     if err is not None:
---> 80         raise err
     81
/usr/lib64/python3.6/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     69                 sock.bind(source_address)
---> 70             sock.connect(sa)
     71             return sock

ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
/usr/lib64/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    599                                                   body=body, headers=headers,
--> 600                                                   chunked=chunked)
    601

/usr/lib64/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    353         else:
--> 354             conn.request(method, url, **httplib_request_kw)
    355

/usr/lib64/python3.6/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1253         """Send a complete request to the server."""
-> 1254         self._send_request(method, url, body, headers, encode_chunked)
   1255

/usr/lib64/python3.6/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1299             body = _encode(body, 'body')
-> 1300         self.endheaders(body, encode_chunked=encode_chunked)
   1301

/usr/lib64/python3.6/http/client.py in endheaders(self, message_body, encode_chunked)
   1248             raise CannotSendHeader()
-> 1249         self._send_output(message_body, encode_chunked=encode_chunked)
   1250

/usr/lib64/python3.6/http/client.py in _send_output(self, message_body, encode_chunked)
   1035         del self._buffer[:]
-> 1036         self.send(msg)
   1037

/usr/lib64/python3.6/http/client.py in send(self, data)
    973             if self.auto_open:
--> 974                 self.connect()
    975             else:

/usr/lib64/python3.6/site-packages/urllib3/connection.py in connect(self)
    180     def connect(self):
--> 181         conn = self._new_conn()
    182         self._prepare_conn(conn)

/usr/lib64/python3.6/site-packages/urllib3/connection.py in _new_conn(self)
    167             raise NewConnectionError(
--> 168                 self, "Failed to establish a new connection: %s" % e)
    169

NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fda72b6c710>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
/usr/lib64/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    448                     retries=self.max_retries,
--> 449                     timeout=timeout
   450                 )

/usr/lib64/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    637             retries = retries.increment(method, url, error=e, _pool=self,
--> 638                                         _stacktrace=sys.exc_info()[2])
    639             retries.sleep()

/usr/lib64/python3.6/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    398         if new_retry.is_exhausted():
--> 399             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    400

MaxRetryError: HTTPConnectionPool(host='localhost', port=37429): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fda72b6c710>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
~/.local/lib64/python3.6/site-packages/plotly/io/_orca.py in to_image(fig, format, width, height, scale, validate)
   1558         response = request_image_with_retrying(
-> 1559             figure=fig_dict, format=format, scale=scale, width=width, height=height
   1560         )

~/.local/lib64/python3.6/site-packages/retrying.py in wrapped_f(*args, **kw)
     48             def wrapped_f(*args, **kw):
---> 49                 return Retrying(*dargs, **dkw).call(f, *args, **kw)
     50

~/.local/lib64/python3.6/site-packages/retrying.py in call(self, fn, *args, **kwargs)
    211                     # get() on an attempt with an exception should cause it to be raised, but raise just in case
--> 212                     raise attempt.get()
    213                 else:

~/.local/lib64/python3.6/site-packages/retrying.py in get(self, wrap_exception)
    246             else:
--> 247                 six.reraise(self.value[0], self.value[1], self.value[2])
    248         else:

/usr/lib64/python3.6/site-packages/six.py in reraise(tp, value, tb)
    692                 raise value.with_traceback(tb)
--> 693             raise value
    694         finally:

~/.local/lib64/python3.6/site-packages/retrying.py in call(self, fn, *args, **kwargs)
    199             try:
--> 200                 attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
    201             except:

~/.local/lib64/python3.6/site-packages/plotly/io/_orca.py in request_image_with_retrying(**kwargs)
   1467     json_str = json.dumps(request_params, cls=_plotly_utils.utils.PlotlyJSONEncoder)
-> 1468     response = post(server_url + "/", data=json_str)
   1469

/usr/lib64/python3.6/site-packages/requests/api.py in post(url, data, json, **kwargs)
    115
--> 116     return request('post', url, data=data, json=json, **kwargs)
    117

/usr/lib64/python3.6/site-packages/requests/api.py in request(method, url, **kwargs)
     59     with sessions.Session() as session:
---> 60         return session.request(method=method, url=url, **kwargs)
     61
/usr/lib64/python3.6/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    532         send_kwargs.update(settings)
--> 533         resp = self.send(prep, **send_kwargs)
    534

/usr/lib64/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)
    645         # Send the request
--> 646         r = adapter.send(request, **kwargs)
    647

/usr/lib64/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    515
--> 516             raise ConnectionError(e, request=request)
    517

ConnectionError: HTTPConnectionPool(host='localhost', port=37429): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fda72b6c710>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-10-d9b104bc8a09> in <module>
----> 1 fig.write_image("test.pdf")

~/.local/lib64/python3.6/site-packages/plotly/basedatatypes.py in write_image(self, *args, **kwargs)
   2822         import plotly.io as pio
   2823
-> 2824         return pio.write_image(self, *args, **kwargs)
   2825
   2826     # Static helpers
~/.local/lib64/python3.6/site-packages/plotly/io/_orca.py in write_image(fig, file, format, scale, width, height, validate)
   1765     # Do this first so we don't create a file if image conversion fails
   1766     img_data = to_image(
-> 1767         fig, format=format, scale=scale, width=width, height=height, validate=validate
   1768     )
   1769

~/.local/lib64/python3.6/site-packages/plotly/io/_orca.py in to_image(fig, format, width, height, scale, validate)
   1589 {info}
   1590 """.format(
-> 1591                         info=status_str
   1592                     )
   1593                 )

ValueError:
For some reason plotly.py was unable to communicate with the
local orca server process, even though the server process seems to be running.

Please review the process and connection information below:

orca status
-----------
    state: running
    executable: /home/fenho/.local/bin/orca
    version: 1.2.1
    port: 37429
    pid: 58875
    command: ['/home/fenho/.local/bin/orca', 'serve', '-p', '37429', '--plotly', '/home/fenho/.local/lib64/python3.6/site-packages/plotly/package_data/plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js']

I tried the solution offered in https://github.com/plotly/orca/issues/164 (adding time.sleep) to no avail. So this must be another problem.

Relevant info:

docker container inspect 362580f5fc96

[
    {
        "Id": "362580f5fc96d63f6823f97d8911e0d9c946d074a1f41ef68f4c994541d95606",
        "Created": "2020-01-13T21:56:51.045184856Z",
        "Path": "/entrypoint.sh",
        "Args": [
            "serve",
            "-p",
            "32923",
            "--plotly",
            "/home/fenho/.local/lib64/python3.6/site-packages/plotly/package_data/plotly.min.js",
            "--graph-only",
            "--mathjax",
            "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 61349,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-01-13T21:56:52.991441354Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:36fab586c73efdce2be6d457118755c5fe2f098555ff4cbacad9d5a18d1c6111",
        "ResolvConfPath": "/var/lib/docker/containers/362580f5fc96d63f6823f97d8911e0d9c946d074a1f41ef68f4c994541d95606/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/362580f5fc96d63f6823f97d8911e0d9c946d074a1f41ef68f4c994541d95606/hostname",
        "HostsPath": "/var/lib/docker/containers/362580f5fc96d63f6823f97d8911e0d9c946d074a1f41ef68f4c994541d95606/hosts",
        "LogPath": "/var/lib/docker/containers/362580f5fc96d63f6823f97d8911e0d9c946d074a1f41ef68f4c994541d95606/362580f5fc96d63f6823f97d8911e0d9c946d074a1f41ef68f4c994541d95606-json.log",
        "Name": "/exciting_bell",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/home/fenho/stuff:/home/fenho/stuff"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "host",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": true,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Capabilities": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/b3a4304eef749950022efb8b3579e76cc216a2d2cc74da99266e6819a4359c9c-init/diff:/var/lib/docker/overlay2/20bddad60e45f58f78a2e1a02b973195fce670bf4ce84d4910f906dda59418f5/diff:/var/lib/docker/overlay2/59bb236f1bc57e03170de014796590ad0787d15f2fcce9030e7208e83cd669e8/diff:/var/lib/docker/overlay2/dad8d20246b5352d734f46fffd843997e9ec90aab6b81a19fe58b2a69ea86cc8/diff:/var/lib/docker/overlay2/83365bb9154d4bd1487091202e70744fbba8b398950d043dc7f8931360d207f5/diff:/var/lib/docker/overlay2/da3279be9e58fad41f318e7bae47493609180221e06e328f140bb06e7a534d5b/diff:/var/lib/docker/overlay2/ca4bc4a151cb70e8dcba6d16c2b4ca82ad7d59fbb9ea3287f03b5571494fca49/diff:/var/lib/docker/overlay2/a99ba471202f08e0c14659eb97657503181386095abacd382410eb3856323301/diff:/var/lib/docker/overlay2/cc8a7240e1227ac2b092079f0572a699527d860d639cd48f7c2b7070f627b6e6/diff:/var/lib/docker/overlay2/36de061905454af983e6d82dbd65a94e8fde8bde919be213653fd50915bfb07f/diff:/var/lib/docker/overlay2/9bfc0be3957fc9740cd3fa510677e4df43fdedcf3e7a5ba9498edd05c7202f5a/diff:/var/lib/docker/overlay2/60f98eff267576ac7d2edb02c907a6a4eb349ffc3dd0350d34b5fa930e2c9ce3/diff:/var/lib/docker/overlay2/cab43f9c2e76e52f597853b22ad3b1232d97ba7d851478896c28b5363fde07c4/diff:/var/lib/docker/overlay2/d1b524fcf7eee95cd7b4a674cb62a85ad776277cd1f1fca4b74fdb4be5433c10/diff:/var/lib/docker/overlay2/979e2fea878454eff13e75e09e656147291480ade400b7cd828a5ac51cce3a0a/diff:/var/lib/docker/overlay2/8a4e709b5bfcfa0658b1e469caee1234ddc9caf2bdb1a80481e43f2d35f4de2b/diff:/var/lib/docker/overlay2/571880c498d6c3d961d39087f30ac02f4800a9ea84f4eae36576d7a6151b28d0/diff:/var/lib/docker/overlay2/6fbe552954ecd22597642e1f62ba8f65b222ef4b4150cb7143df946a68a84680/diff:/var/lib/docker/overlay2/fd1146deaca1f3d5191db1c38a4d15fc3b1a3221ed7f126668bec7927eb1696c/diff:/var/lib/docker/overlay2/32efb686d2f2e85f02e5be2fb7eeccdc36aceaeb53cba2b67cef525b4532a4c9/diff:/var/lib/docker/overlay2/4f7629849a9ad63035dc6a27d71ed1b5bfe8d07103b3255758d426285152f8b2/diff:/var/lib/docker/overlay2/ea537f1305e5e2763e68f7645b1d87db229386e0e14987a64f9ca5bfac08e15b/diff:/var/lib/docker/overlay2/cd143416e3526a0fe83045d3df50c51ddd304e16cdccec0ff626a03aa9bea3d9/diff:/var/lib/docker/overlay2/d98482a27f4e52e38923b221185483633de8aff72b036ad1c0428792731fb16e/diff:/var/lib/docker/overlay2/b774ba2e7790fa0e00598d565fe5cf4adddd61b965803057574854292332e1ca/diff",
                "MergedDir": "/var/lib/docker/overlay2/b3a4304eef749950022efb8b3579e76cc216a2d2cc74da99266e6819a4359c9c/merged",
                "UpperDir": "/var/lib/docker/overlay2/b3a4304eef749950022efb8b3579e76cc216a2d2cc74da99266e6819a4359c9c/diff",
                "WorkDir": "/var/lib/docker/overlay2/b3a4304eef749950022efb8b3579e76cc216a2d2cc74da99266e6819a4359c9c/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/home/fenho/stuff",
                "Destination": "/home/fenho/stuff",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "localhost.localdomain",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": true,
            "AttachStderr": true,
            "ExposedPorts": {
                "9091/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NPM_CONFIG_LOGLEVEL=info",
                "NODE_VERSION=6.11.3"
            ],
            "Cmd": [
                "serve",
                "-p",
                "32923",
                "--plotly",
                "/home/fenho/.local/lib64/python3.6/site-packages/plotly/package_data/plotly.min.js",
                "--graph-only",
                "--mathjax",
                "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"
            ],
            "Image": "quay.io/plotly/orca",
            "Volumes": null,
            "WorkingDir": "/home/fenho/stuff",
            "Entrypoint": [
                "/entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "9dda5f35bba43f16d9baa1bcb4cd438fa3a79265291e79afc46b3088b57fcf87",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/default",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "host": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "2741861bf06d9b4cfd4cfb69ae69e537a9bd62ab442a3cbcb2fb8311d92243c4",
                    "EndpointID": "37577765d5f076a042a5109af80b719447ad86539c37222afba93ee416a0dbe9",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
        }
    }
]

docker container logs 362580f5fc96

/usr/share/fonts/user: skipping, existing cache is valid: 0 fonts, 0 dirs
/var/cache/fontconfig: cleaning cache directory
/root/.cache/fontconfig: not cleaning non-existent cache directory
/root/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded
 New Monit id: 98fd6bb8e52e8b0e5f0a3c13d6f9b9bf
 Stored in '/root/.monit.id'
Starting Monit 5.25.1 daemon with http interface at [*]:2812
'localhost.localdomain' Monit 5.25.1 started
Spinning up server with pid: 41
{"severity":"ERROR","textPayload":"Error: Provided path to plotly.js bundle does not exist and does not correspond to a release version"}
'xvfb' trying to restart
'xvfb' restart: '/usr/local/bin/xvfb_wrapper'
Spinning up server with pid: 120
{"severity":"ERROR","textPayload":"Error: Provided path to plotly.js bundle does not exist and does not correspond to a release version"}
'xvfb' trying to restart
'xvfb' restart: '/usr/local/bin/xvfb_wrapper'
Spinning up server with pid: 201
{"severity":"ERROR","textPayload":"Error: Provided path to plotly.js bundle does not exist and does not correspond to a release version"}
'xvfb' trying to restart
'xvfb' restart: '/usr/local/bin/xvfb_wrapper'
Spinning up server with pid: 281
{"severity":"ERROR","textPayload":"Error: Provided path to plotly.js bundle does not exist and does not correspond to a release version"}
'xvfb' trying to restart
'xvfb' restart: '/usr/local/bin/xvfb_wrapper'
Spinning up server with pid: 361
{"severity":"ERROR","textPayload":"Error: Provided path to plotly.js bundle does not exist and does not correspond to a release version"}

cat ~/.local/bin/orca

#!/usr/bin/env bash

DOCKER_IMAGE=quay.io/plotly/orca

if [[ $1 == "--help" || $1 == "--version" || $1 == "graph" || $1 == "serve" ]]; then
    docker run  --network host \
      -v "$(pwd)":"$(pwd)" -w "$(pwd)" \
       "$DOCKER_IMAGE" "$@"
else
    echo "Unrecognized orca command. Run \`$0 --help\` for more info"
fi

pip3 list

Package            Version  
------------------ ---------
attrs              19.3.0   
backcall           0.1.0    
bleach             3.1.0    
certifi            2019.6.16
cffi               1.13.2   
chardet            3.0.4    
cryptography       2.8      
Cython             0.29.4   
decorator          4.4.1    
defusedxml         0.6.0    
docutils           0.14     
entrypoints        0.3      
flaggie            0.2.1    
gdbus-codegen      2.60.7   
gemato             14.3     
gentoolkit         0.4.6    
idna               2.8      
importlib-metadata 1.4.0    
ipaddress          1.0.22   
ipykernel          5.1.3    
ipython            7.11.1   
ipython-genutils   0.2.0    
jedi               0.15.2   
Jinja2             2.10.3   
json5              0.8.5    
jsonschema         3.2.0    
jupyter-client     5.3.4    
jupyter-core       4.6.1    
jupyterlab         1.2.4    
jupyterlab-server  1.0.6    
layman             2.4.2    
lxml               4.3.3    
M2Crypto           0.31.0   
Mako               1.0.7    
MarkupSafe         1.1.1    
meson              0.51.2   
mistune            0.8.4    
more-itertools     8.1.0    
nbconvert          5.6.1    
nbformat           5.0.3    
ndg-httpsclient    0.4.0    
notebook           6.0.2    
numpy              1.18.1   
pandas             0.25.3   
pandocfilters      1.4.2    
parso              0.5.2    
patsy              0.5.1    
pexpect            4.7.0    
pickleshare        0.7.5    
pip                19.3.1   
plotly             4.4.1    
ply                3.11     
portage            2.3.79   
prometheus-client  0.7.1    
prompt-toolkit     3.0.2    
psutil             5.6.7    
ptyprocess         0.6.0    
pyasn1             0.4.2    
pyblake2           1.1.2    
pycairo            1.18.2   
pycparser          2.19     
pycryptodome       3.6.6    
Pygments           2.4.2    
PyGObject          3.32.1   
pyOpenSSL          19.0.0   
pyrsistent         0.15.7   
PySocks            1.6.8    
python-dateutil    2.8.1    
pytz               2019.3   
pyxattr            0.6.0    
pyzmq              18.1.1   
requests           2.21.0   
retrying           1.3.3    
scipy              1.4.1    
Send2Trash         1.5.0    
setuptools         42.0.2   
six                1.12.0   
ssl-fetch          0.4      
statsmodels        0.10.2   
terminado          0.8.3    
testpath           0.4.4    
tornado            6.0.3    
traitlets          4.3.3    
urllib3            1.24.2   
wcwidth            0.1.8    
webencodings       0.5.1    
youtube-dl         2020.1.1 
zipp               0.6.0    

I am using linux and did some tests to see if docker was working correctly. I tried https://github.com/qdm12/port-checker and other images. coudn't find any problems.

fthalabi avatar Jan 13 '20 22:01 fthalabi

I am sorry you are running into all sorts of issues @fthalabi and thank you for trying to get this work!

It seems that plotly.py is trying to start Orca on a different port which may not be accessible to the outside world (ie. your host machine). Using --net=host may fix the problem.

However, one cleaner solution IMHO and the one I typically use is to launch Orca myself and point plotly.py to it. So if start Orca on localhost on port 9091, I simply have to do the following from python:

import plotly.io as pio
pio.orca.config.server_url = "http://localhost:9091"

and then things should just work :smile_cat:

antoinerg avatar Jan 13 '20 22:01 antoinerg

I'm sorry to bother, I really did try to get it running before asking.

import plotly.io as pio pio.orca.config.server_url = "http://localhost:9091"

Do you use only those options @antoinerg ? I don't get a server with that.

In [1]:import plotly.io as pio
In [2]:pio.orca.config.server_url = "http://localhost:9091"
In [3]:pio.orca.ensure_server()
In [4]:pio.orca.status
Out [4]:
orca status
-----------
    state: unvalidated
    executable: None
    version: None
    port: None
    pid: None
    command: None

Thanks for the help.

fthalabi avatar Jan 14 '20 18:01 fthalabi

@fthalabi Yes the above should work if you have an Orca instance running and accessible at the address you provided. Just create a figure and write an image to check:

fig = go.Figure(
    data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],
    layout=go.Layout(
         title=go.layout.Title(text="A Bar Chart")
    )
)
fig.write_image("test.pdf")

antoinerg avatar Jan 14 '20 19:01 antoinerg

I'm having this issue as well. I have a docker-compose with a plotly environment in one container and the quay.io/plotly/orca image running in another container.

I know the orca server is running because I can go to localhost:9091 in my browser and the request is logged in the container. However, when trying to use pio in my plotly container, I cannot connect to the server.

Plotly.py was unable to communicate with the orca server at http://localhost:9091

Please check that the server is running and accessible.

hiramf avatar Feb 21 '20 18:02 hiramf

Just to be sure @hiramf, can you go to localhost:9091 from within the container making the call to Orca?

antoinerg avatar Feb 21 '20 18:02 antoinerg

@antoinerg, negative, so more likely an issue with my configuration? Using netcat and python/requests both yielded connection refused.

hiramf avatar Feb 21 '20 18:02 hiramf

@antoinerg, negative, so more likely an issue with my configuration?

Yes! The problem is that localhost is a different destination depending on where it's called from. From the container, you can try to reach Orca (running on your host machine) by replacing localhost by the IP address of your host.

antoinerg avatar Feb 21 '20 19:02 antoinerg

Got it! Confirmed working by spinning up an instance on Azure and setting pio.orca.config.server_url.

One thing to note is that pio.orca.status still returns even after successfully running fig.write_image(test.png):

>>> pio.orca.status
orca status
-----------
    state: unvalidated
    executable: None
    version: None
    port: None
    pid: None
    command: None

hiramf avatar Feb 21 '20 19:02 hiramf

@hiramf I'm glad this fixed your issue!

About the pio.orca.status, I agree that the output is not user-friendly at all. I will open an issue over at https://github.com/plotly/plotly.py

EDIT: https://github.com/plotly/plotly.py/issues/2222

antoinerg avatar Feb 21 '20 19:02 antoinerg

Hi team, I've produced the same code and followed the steps indicated and still getting a connection error.

import time
import plotly.io as pio
import plotly.graph_objects as go
plotly.io.orca.ensure_server()
time.sleep(30)
fig = go.Figure(
    data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],
    layout=go.Layout(
         title=go.layout.Title(text="A Bar Chart")
    )
)
fig.write_image("test.pdf")

After this I get a MaxRetryError. I've tried just about everything I can find, including setting separate server_urls and ports, but to no avail. I'm admittedly new to this and a bit confused:

Yes! The problem is that localhost is a different destination depending on where it's called from. From the container, you can try to reach Orca (running on your host machine) by replacing localhost by the IP address of your host.

I can get a Plotly images to show in the browser via the traditional fig.show(), and when I create an image with orca according to documentation, it works fine (although my '.svg' still produces a '.png', which seems another issue entirely.

orca graph "{ \"data\": [{\"y\": [1,2,1]}] }" -o fig.png

I should finally say I'm not using docker, I'm just running this on a Jupyter Notebook, but I've tried running from command line as well. I've been able to get the orca server up and running, but could it be some Firewall issue? I have almost 0 experience with that unfortunately, so not sure how to troubleshoot that aspect. After scouring the web this issue thread seemed my best hope... I appreciate any help or direction, thanks!

---------------------------------------------------------------------------
ConnectionRefusedError                    Traceback (most recent call last)
~\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py in _new_conn(self)
    155         try:
--> 156             conn = connection.create_connection(
    157                 (self._dns_host, self.port), self.timeout, **extra_kw

~\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py in create_connection(address, timeout, source_address, socket_options)
     83     if err is not None:
---> 84         raise err
     85 

~\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py in create_connection(address, timeout, source_address, socket_options)
     73                 sock.bind(source_address)
---> 74             sock.connect(sa)
     75             return sock

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=63716): Max retries exceeded with url: // (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001B388065310>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

murphdawg02 avatar Apr 10 '20 05:04 murphdawg02

I was able to avoid the write_image() phenomenon altogether by using plotly iplot. Not the static image export service I was hoping to use, but it works.

The below downloads an svg... and crisp images have been restored!

from plotly.offline import iplot
import plotly.graph_objs as go
import numpy as np

np.random.seed(1)

N = 100
random_x = np.linspace(0, 1, N)
random_y0 = np.random.randn(N) + 5
random_y1 = np.random.randn(N)
random_y2 = np.random.randn(N) - 5

# Create traces
fig = go.Figure()
fig.add_trace(go.Scatter(x=random_x, y=random_y0,
                    mode='lines',
                    name='lines'))
fig.add_trace(go.Scatter(x=random_x, y=random_y1,
                    mode='lines+markers',
                    name='lines+markers'))
fig.add_trace(go.Scatter(x=random_x, y=random_y2,
                    mode='markers', name='markers'))

fig
iplot(fig, image='svg', filename='line_test_image')

murphdawg02 avatar Apr 10 '20 15:04 murphdawg02

I've been able to get the orca server up and running, but could it be some Firewall issue?

Can you verify that you're able to go to 127.0.0.1:9091 (or whichever port your orca server is running on) and see that you get a response? (should say json parse error in the browser)

Also, the error message you posted says it is looking at a different port than what I believe is the default (9091).

hiramf avatar Apr 10 '20 16:04 hiramf