Steven
05/01/2024, 9:03 PMRuntimeError: Failed to generate Dockerfile. Dockerfile already exists in the current directory.
i notice that
def generate_default_dockerfile(context: Optional[Path] = None):
optionally can take a path context, but i don't see a way to specify that from my simple flow:
if __name__ == "__main__":
test_processing_flow.deploy(
name="test-processor-flow",
work_pool_name="test-docker-pool",
image="test-processor-flow:latest",
push=False
)
am i missing something?Nate
05/01/2024, 9:08 PM.deploy()
to build an image for you (because you already have one) then you can set build=False
alongside your push=False
Steven
05/01/2024, 9:51 PMSteven
05/01/2024, 9:51 PMNate
05/01/2024, 11:29 PMNate
05/01/2024, 11:29 PMSteven
05/01/2024, 11:35 PMNate
05/01/2024, 11:59 PMSteven
05/02/2024, 12:34 AMNate
05/02/2024, 12:40 AMSteven
05/02/2024, 6:20 PM` File "/Users/user/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/utilities/dockerutils.py", line 114, in docker_client
raise RuntimeError(
RuntimeError: This error is often thrown because Docker is not running. Please ensure Docker is running.
Steven
05/02/2024, 6:20 PMfrom prefect.deployments import DeploymentImage
from neo4j_python.prefect.flows.malware_processor_flow import malware_processing_flow
if __name__ == "__main__":
malware_processing_flow.deploy(
name="malware-processor-flow",
work_pool_name="stevens-docker-pool",
image=DeploymentImage(
name="malware-processor-image",
tag="latest",
dockerfile="Dockerfile.malware_processor_flow"
),
push=False
)
Steven
05/02/2024, 6:21 PM# We're using the latest version of Prefect with Python 3.10
FROM prefecthq/prefect:2-python3.11
# Add our requirements.txt file to the image and install dependencies
# poetry export --format=requirements.txt --output=requirements.txt
COPY requirements.txt .
RUN pip install -r requirements.txt --trusted-host <http://pypi.python.org|pypi.python.org> --no-cache-dir
# Add our flow code to the image
COPY ../flows /opt/prefect/flows
# Run our flow script when the container starts
CMD ["python", "flows/malware_processor_flow.py"]
Steven
05/02/2024, 6:21 PMNate
05/02/2024, 6:41 PMSteven
05/02/2024, 6:43 PMTraceback (most recent call last):
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/connectionpool.py", line 791, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/connectionpool.py", line 497, in _make_request
conn.request(
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/connection.py", line 395, in request
self.endheaders()
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/http/client.py", line 1281, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/http/client.py", line 1041, in _send_output
self.send(msg)
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/http/client.py", line 979, in send
self.connect()
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/transport/unixconn.py", line 27, in connect
sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/connectionpool.py", line 845, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/util/retry.py", line 470, in increment
raise reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/util/util.py", line 38, in reraise
raise value.with_traceback(tb)
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/connectionpool.py", line 791, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/connectionpool.py", line 497, in _make_request
conn.request(
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/urllib3/connection.py", line 395, in request
self.endheaders()
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/http/client.py", line 1281, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/http/client.py", line 1041, in _send_output
self.send(msg)
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/http/client.py", line 979, in send
self.connect()
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/transport/unixconn.py", line 27, in connect
sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/api/client.py", line 214, in _retrieve_server_version
return self.version(api_version=False)["ApiVersion"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/api/daemon.py", line 181, in version
return self._result(self._get(url), json=True)
^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/api/client.py", line 237, in _get
return self.get(url, **self._set_request_timeout(kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/requests/adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/utilities/dockerutils.py", line 110, in docker_client
client = docker.DockerClient.from_env()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/client.py", line 96, in from_env
return cls(
^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/client.py", line 45, in __init__
self.api = APIClient(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/api/client.py", line 197, in __init__
self._version = self._retrieve_server_version()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/docker/api/client.py", line 221, in _retrieve_server_version
raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/shanna/code/intel-graph/src/neo4j_python/prefect/deployments/malware_processor_deploy.py", line 6, in <module>
malware_processing_flow.deploy(
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 296, in coroutine_wrapper
return call()
^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 432, in __call__
return self.result()
^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 318, in result
return self.future.result(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 179, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 389, in _run_async
result = await coro
^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/flows.py", line 1098, in deploy
deployment_ids = await deploy(
^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/deployments/runner.py", line 980, in deploy
image.build()
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/deployments/runner.py", line 835, in build
build_image(**build_kwargs)
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/utilities/dockerutils.py", line 164, in build_image
with docker_client() as client:
File "/Users/shanna/.pyenv/versions/3.11.4/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/Users/shanna/.pyenv/versions/3.11.4/envs/intel-graph/lib/python3.11/site-packages/prefect/utilities/dockerutils.py", line 114, in docker_client
raise RuntimeError(
RuntimeError: This error is often thrown because Docker is not running. Please ensure Docker is running.
Nate
05/02/2024, 6:46 PMpackages/docker/transport/unixconn.py", line 27, in connect
sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
can you do this?
» python -c "import docker; print(docker.DockerClient.from_env())"
<docker.client.DockerClient object at 0x100950a40>
Steven
05/02/2024, 6:47 PMNate
05/02/2024, 6:47 PMSteven
05/02/2024, 6:48 PMNate
05/02/2024, 6:48 PMSteven
05/02/2024, 6:48 PMSteven
05/02/2024, 6:48 PMshanna-mba:~ shanna$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80ab7ffc5a95 postgres:14 "docker-entrypoint.s…" 7 weeks ago Up 24 hours (healthy) 0.0.0.0:5432->5432/tcp intel-graph-api-db-1
Nate
05/02/2024, 6:49 PMunset DOCKER_HOST
?Steven
05/02/2024, 6:49 PMSteven
05/02/2024, 6:49 PMSteven
05/02/2024, 6:50 PMNate
05/02/2024, 6:52 PMNate
05/02/2024, 6:52 PMls /var/run/ | grep docker.sock
Nate
05/02/2024, 6:52 PMsudo
for other docker stuff? maybe a permissions thing somehowSteven
05/02/2024, 6:53 PMSteven
05/02/2024, 6:53 PMls /var/run/ | grep docker.sock
didnt return anythingNate
05/02/2024, 6:53 PMNate
05/02/2024, 6:54 PMclass DockerClient:
"""
A client for communicating with a Docker server.
Example:
>>> import docker
>>> client = docker.DockerClient(base_url='<unix://var/run/docker.sock>')
Args:
base_url (str): URL to the Docker server. For example,
``unix:///var/run/docker.sock`` or ``<tcp://127.0.0.1:1234>``.
version (str): The version of the API to use. Set to ``auto`` to
automatically detect the server's version. Default: ``1.35``
timeout (int): Default timeout for API calls, in seconds.
tls (bool or :py:class:`~docker.tls.TLSConfig`): Enable TLS. Pass
``True`` to enable it with default options, or pass a
:py:class:`~docker.tls.TLSConfig` object to use custom
configuration.
user_agent (str): Set a custom user agent for requests to the server.
credstore_env (dict): Override environment variables when calling the
credential store process.
use_ssh_client (bool): If set to `True`, an ssh connection is made
via shelling out to the ssh client. Ensure the ssh client is
installed and configured on the host.
max_pool_size (int): The maximum number of connections
to save in the pool.
"""
def __init__(self, *args, **kwargs):
self.api = APIClient(*args, **kwargs)
Steven
05/02/2024, 6:55 PMfind / -name "docker.sock" 2> /dev/null
Steven
05/02/2024, 6:56 PMSteven
05/02/2024, 6:57 PM/System/Volumes/Data/Users/shanna/.docker/run/docker.sock
Nate
05/02/2024, 6:58 PMset DOCKER_HOST
to that - but personally i would explore reinstalling / having it at the standard placeSteven
05/02/2024, 6:59 PMNate
05/02/2024, 6:59 PMNate
05/02/2024, 6:59 PMSteven
05/02/2024, 7:00 PMDOCKER_HOST=/System/Volumes/Data/Users/shanna/.docker/run/docker.sock PYTHONPATH=src/ python src/neo4j_python/prefect/deployments/malware_processor_deploy.py