Skip to content

Commit

Permalink
Merge branch 'release/4.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Oblath committed Mar 7, 2024
2 parents 988b077 + 3b6d6ab commit f9f0b4a
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 8 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ on:
env:
REGISTRY: ghcr.io
REGISTRY_OLD: docker.io
BASE_IMAGE_USER: driplineorg
BASE_IMAGE_USER: ghcr.io/driplineorg
BASE_IMAGE_REPO: dripline-cpp
BASE_IMAGE_VER: 'v2.8.8'
BASE_IMAGE_VER: 'v2.9.0'

jobs:

Expand Down Expand Up @@ -42,6 +42,7 @@ jobs:
img_tag=${{ env.BASE_IMAGE_TAG }}
platforms: linux/amd64


build_and_push:

runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5) # <3.5 is deprecated by CMake
project( DriplinePy VERSION 4.6.1 )
project( DriplinePy VERSION 4.7.0 )

cmake_policy( SET CMP0074 NEW )

Expand Down
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG img_user=driplineorg
ARG img_user=ghcr.io/driplineorg
ARG img_repo=dripline-cpp
#ARG img_tag=hotfix_2.6.2
ARG img_tag=v2.8.8
ARG img_tag=v2.9.0
#ARG img_arch=arm

FROM ${img_user}/${img_repo}:${img_tag}
Expand All @@ -12,6 +12,13 @@ FROM ${img_user}/${img_repo}:${img_tag}
## into the ld.so.conf cache... use this only when developing and adding libs
ENV LD_LIBRARY_PATH /usr/local/lib

RUN apt-get update && \
apt-get clean && \
apt-get --fix-missing -y install \
libpq-dev && \
rm -rf /var/lib/apt/lists/*


RUN pip install ipython
RUN pip install pytest

Expand All @@ -28,7 +35,7 @@ COPY README.md /usr/local/src_py/README.md
COPY pytest.ini /usr/local/src_py/pytest.ini


RUN pip install /usr/local/src_py
RUN pip install -v /usr/local/src_py

#RUN cd /usr/local/src_py &&\
# python setup.py install
Expand Down
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
## the appVersion is used as the container image tag for the main container in the pod from the deployment
## it can be overridden by a values.yaml file in image.tag
appVersion: "v4.6.1"
appVersion: "v4.7.0"
description: Deploy a dripline-python microservice
name: dripline-python
version: 1.1.2
113 changes: 113 additions & 0 deletions doc/extending.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
==================
Extending Dripline
==================

Dripline-python can be conveniently extended using the namespace plugin method. The controls-guide
repository includes an example set of files that can be copied into a new repository to create
an extension to the ``dripline`` namespace. Please see the
`controls-guide documentation <https://controls-guide.readthedocs.io/en/latest/>`_
to follow a walkthrough that will implement a new dripline extension.

Adding a Service Class
======================

Adding an Endpoint Class
========================

There are some situations in which you will need to create your own endpoint class to add functionality that's not
available in the the ``core`` or ``implementations`` sub-packages. A new endpoing class can be derived from
``Endpoint``, ``Entity``, or any of the endpoint classes from ``dripline.implementations``.

Adding ``CMD`` Handlers
~~~~~~~~~~~~~~~~~~~~~~~

The default behavior for dripline-python endpoints (as implemented in ``Endpoint``) is for any function attribute
of an endpoint class to be addressable with an ``OP_CMD`` request.

We'll cover the primary features that will need to be addressed, followed by an example that
will illustrate everything.

**Basic Setup**

.. code-block:: python
def my_cmd(self, [args], [**kwargs])
[do something]
return [a variable]
This can be addressed with ``dl-agent`` by an ``OP_CMD`` request::

dl-agent cmd an_endpoint -s my_cmd [args] [kwargs]

**Arguments**

The function can include both positional arguments and keyword arguments. Positional arguments
would be defined as:

.. code-block:: python
def concatenate(self, an_arg1, an_arg2):
return repr(an_arg1) + repr(an_arg2)
and addressed with ``dl-agent`` as::

dl-agent cmd an_endpoint -s concatenate "My number is " 5

The return value would be ``My number is 5``.

Keyword arguments would be defined as:

.. code-block:: python
def make_list(self, a_kwarg1, a_kwarg2=100):
return [a_kwarg1, a_kwarg2]
and addressed with ``dl-agent`` as::

dl-agent cmd an_endpoint -s make_list a_kwarg2=20000 a_kwarg1=1000

The return value would be ``[1000, 20000]```.

**Return**

The return values can be null (returning ``None`` in Python), scalar values (integers, floats, or strings),
array-like data (a list in Python), or dictionary-like data (a dict in Python).

**Example**

Endpoint definition:

.. code-block:: python
class AnEndpoint(dripline.core.Entity):
def __init__(self, base_str="The answer is: "):
self.base = base_str
def on_get(self):
return self.base_str
def on_set(self, new_value):
self.base_str = new_value
def concatenate(self, an_arg1, an_arg2):
return self.base + repr(an_arg1) + repr(an_arg2)
def make_list(self, a_kwarg1, a_kwarg2=100):
return self.base + f"{[a_kwarg1, a_kwarg2]}
Usage (with ``dripline.core.Interface``):

.. code-block:: python
import dripline.core.Interface as Interface
ifc = Interface([config info])
print( ifc.get('an_endpoint') )
print( ifc.cmd('an_endpoint', 'concatenate', 'Hello, ', 'world') )
ifc.set('an_endpoint', 'As a list: ')
print( ifc.cmd('an_endpoint', 'make_list', a_kwarg1='Hello, ', a_kwarg2='world') )
The output should be::

The answer is:
The answer is: Hello, world
As a list: ['Hello, ', 'world']
2 changes: 2 additions & 0 deletions doc/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ It can be installed from most package managers or by following their instruction
You will need `CMake <https://cmake.org/>`_ to build the C++ wrappers.
Version 3.5 or higher is required.
It can be installed from most package managers or by following their instructions.
Note that this is not included as a dependency in the Python installation process.
See ``pyproject.toml`` for more details.

Python Libraries
****************
Expand Down
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ the components in a running service.
:maxdepth: 2

getting_started
extending
dl_serve
API Documentation <apidoc/modules>
contribute
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ requires = [
"setuptools-scm>=8.0",
"wheel",
"pybind11>=2.6.0",
"cmake>=3.12",
]
# Removing CMake as a build-system dependency
# This was causing arm/v7 builds to take 4+ hours and often fail.
# CMake is not available as a pre-built wheel for the arm/v7 architecture,
# so it would build CMake from source (hence the hours-long build).
# The failures happened during CMake's testing that happened as part of the build, one test would fail.
# This could be put back in if arm/v7 support is dropped, or a way is found to satisfy this
# requirement based on system-installed (i.e. non-pip) CMake.
# "cmake>=3.12",
build-backend = "setuptools.build_meta"

[project]
Expand Down

0 comments on commit f9f0b4a

Please sign in to comment.