Skip to content

Commit f0b1cab

Browse files
authored
MRG: Merge pull request #529 from octue/feature/add-topic-and-subscription-creation-command
Resolve and fully support service namespacing and revision tagging
2 parents 41931f6 + 235bbd7 commit f0b1cab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1124
-533
lines changed

.github/workflows/python-ci.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,10 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v3
2020
with:
21-
# Set fetch-depth to 0 to fetch all tags (necessary for git-mkver to determine the correct semantic version).
2221
fetch-depth: 0
23-
- uses: actions/setup-python@v2
24-
- name: Install git-mkver
25-
run: |
26-
curl -L https://github.com/idc101/git-mkver/releases/download/v1.2.1/git-mkver-linux-amd64-1.2.1.tar.gz \
27-
| tar xvz \
28-
&& sudo mv git-mkver /usr/local/bin
29-
- name: Install semantic version checker
30-
run: pip install git+https://github.com/octue/conventional-commits
31-
- name: Check version
32-
run: check-semantic-version pyproject.toml
22+
- uses: octue/[email protected]
23+
with:
24+
version_source_type: pyproject.toml
3325

3426
run-tests:
3527
if: "!contains(github.event.head_commit.message, 'skipci')"
@@ -38,7 +30,6 @@ jobs:
3830
USING_COVERAGE: "3.9"
3931
strategy:
4032
matrix:
41-
python: [3.9]
4233
os: [ubuntu-latest, windows-latest, macos-latest]
4334
permissions:
4435
id-token: write
@@ -49,10 +40,10 @@ jobs:
4940
- name: Setup Python
5041
uses: actions/setup-python@v2
5142
with:
52-
python-version: ${{ matrix.python }}
43+
python-version: 3.9
5344

5445
- name: Install Poetry
55-
uses: snok/install-poetry@v1
46+
uses: snok/install-poetry@v1.3.2
5647

5748
- name: Check pyproject.toml file
5849
run: poetry check

.github/workflows/release.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
USING_COVERAGE: '3.9'
1919
strategy:
2020
matrix:
21-
python: [ 3.9 ]
2221
os: [ ubuntu-latest, windows-latest, macos-latest ]
2322
permissions:
2423
id-token: write
@@ -29,14 +28,18 @@ jobs:
2928
- name: Setup Python
3029
uses: actions/setup-python@v2
3130
with:
32-
python-version: ${{ matrix.python }}
31+
python-version: 3.9
3332

3433
- name: Install Poetry
35-
uses: snok/install-poetry@v1
34+
uses: snok/install-poetry@v1.3.2
3635

3736
- name: Check pyproject.toml file
3837
run: poetry check
3938

39+
- name: Get package version
40+
id: get-package-version
41+
run: echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
42+
4043
- name: Install tox
4144
run: pip install tox
4245

@@ -61,24 +64,21 @@ jobs:
6164
files: coverage.xml
6265
fail_ci_if_error: false
6366

67+
outputs:
68+
package_version: ${{ steps.get-package-version.outputs.PACKAGE_VERSION }}
69+
6470
release:
6571
runs-on: ubuntu-latest
6672
needs: run-tests
6773
steps:
6874
- uses: actions/checkout@v3
6975

70-
- name: Install Poetry
71-
uses: snok/install-poetry@v1
72-
73-
- name: Get package version
74-
run: echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_ENV
75-
7676
- name: Create Release
7777
uses: actions/create-release@v1
7878
env:
7979
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, no need to create your own.
8080
with:
81-
tag_name: ${{ env.PACKAGE_VERSION }}
81+
tag_name: ${{ needs.run-tests.outputs.package_version }}
8282
release_name: ${{ github.event.pull_request.title }}
8383
body: ${{ github.event.pull_request.body }}
8484
draft: false
@@ -100,18 +100,12 @@ jobs:
100100

101101
docker:
102102
runs-on: ubuntu-latest
103-
needs: release
103+
needs: [run-tests, release]
104104
timeout-minutes: 300
105105
steps:
106106
- name: Checkout
107107
uses: actions/checkout@v3
108108

109-
- name: Install Poetry
110-
uses: snok/install-poetry@v1
111-
112-
- name: Get package version
113-
run: echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_ENV
114-
115109
- name: Log in to DockerHub
116110
uses: docker/login-action@v1
117111
with:
@@ -123,4 +117,4 @@ jobs:
123117
with:
124118
context: .
125119
push: true
126-
tags: octue/octue-sdk-python:${{ env.PACKAGE_VERSION }}-slim,octue/octue-sdk-python:latest
120+
tags: octue/octue-sdk-python:${{ needs.run-tests.outputs.package_version }}-slim,octue/octue-sdk-python:latest

.github/workflows/update-pull-request.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,12 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v3
21+
- uses: octue/[email protected]
2122
with:
22-
# Set fetch-depth to 0 to fetch all commit history (necessary for compiling pull request description).
23-
fetch-depth: 0
24-
- name: Install release note compiler
25-
run: pip install git+https://github.com/octue/conventional-commits
26-
- name: Compile new pull request description
27-
run: |
28-
echo 'PULL_REQUEST_NOTES<<EOF' >> $GITHUB_ENV
29-
echo "$(compile-release-notes PULL_REQUEST_START --pull-request-url=${{ github.event.pull_request.url }} --api-token=${{ secrets.GITHUB_TOKEN }})" >> $GITHUB_ENV
30-
echo EOF >> $GITHUB_ENV
23+
pull_request_url: ${{ github.event.pull_request.url }}
24+
api_token: ${{ secrets.GITHUB_TOKEN }}
3125
- name: Update pull request body
3226
uses: riskledger/update-pr-description@v2
3327
with:
34-
body: ${{ env.PULL_REQUEST_NOTES }}
28+
body: ${{ env.PULL_REQUEST_DESCRIPTION }}
3529
token: ${{ secrets.GITHUB_TOKEN }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ repos:
7272
- '^dependencies/([a-z][a-z0-9]*)(-[a-z0-9]+)*$'
7373

7474
- repo: https://github.com/octue/conventional-commits
75-
rev: 0.6.4
75+
rev: 0.8.1
7676
hooks:
7777
- id: check-commit-message-is-conventional
7878
stages: [commit-msg]

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN poetry config virtualenvs.create false
1212
# install post-create to install the root package, which will change more rapidly than dependencies.
1313
COPY octue/cloud/deployment/google/dataflow/setup.py setup.py
1414
COPY pyproject.toml poetry.lock ./
15-
RUN poetry install --no-ansi --no-interaction --no-root
15+
RUN poetry install --no-ansi --no-interaction -E dataflow --only=main --no-root -v
1616

1717
COPY . .
18-
RUN poetry install --no-ansi --no-interaction -E dataflow --no-dev -v
18+
RUN poetry install --no-ansi --no-interaction -E dataflow --only=main -v

docs/source/creating_services.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ octue.yaml
114114
.. code-block:: yaml
115115
116116
services:
117+
- namespace: my-organisation
117118
- name: my-app
118119
119120
It may also need the following key-value pairs:
@@ -181,6 +182,75 @@ Dockerfile (optional)
181182

182183
As always, if you need help with this, feel free to drop us a message or raise an issue!
183184

185+
Naming services
186+
===============
187+
188+
.. admonition:: Definitions
189+
190+
Service revision
191+
A specific instance of an Octue service that can be individually addressed. The revision could correspond to a
192+
version of the service, a dynamic development branch for it, or a deliberate duplication or variation of it.
193+
194+
Service revision unique identifier (SRUID)
195+
The combination of a service revisions's namespace, name, and revision tag that uniquely identifies it. For
196+
example, ``octue/my-service:1.3.0`` where the namespace is ``octue``, the name is ``my-service``, and the
197+
revision tag is ``1.3.0``.
198+
199+
Service namespace
200+
The group to which the service belongs e.g. your name or your organisation's name. If in doubt, use the GitHub
201+
handle of the user or organisation publishing the services.
202+
203+
Namespaces must be lower kebab case (i.e. they may contain the letters [a-z], numbers [0-9], and hyphens [-]).
204+
They may not begin or end with hyphens.
205+
206+
Service name
207+
A name to uniquely identify the service within its namespace. This usually corresponds to the name of the GitHub
208+
repository for the service. Names must be lower kebab case (i.e. they may contain the letters [a-z],
209+
numbers [0-9] and hyphens [-]). They may not begin or end with hyphens.
210+
211+
Service revision tag
212+
A tag that uniquely identifies a particular revision of a service. The revision tag could correspond to a commit
213+
hash like ``a3eb45``, a release number like ``0.12.4``, a branch name (e.g. ``development``), a particular
214+
environment the service is deployed in (e.g. ``production``), or a combination like ``0.12.4-production``. Tags
215+
may contain lowercase and uppercase letters, numbers, underscores, periods, and hyphens, but can't start with a
216+
period or a dash. They can contain a maximum of 128 characters. These requirements are the same as the `Docker
217+
tag format <https://docs.docker.com/engine/reference/commandline/tag/>`_.
218+
219+
Service ID
220+
The SRUID is a special case of the service ID. A service ID can be an SRUID or just the service namespace and
221+
name. It can be used to ask a question to a service without specifying a specific revision of it. This enables
222+
asking questions to, for example, the service ``octue/my-service`` and automatically having them routed to its
223+
latest revision. Note that this will be a future feature; currently, you will still be required to provide a
224+
revision tag (i.e. a full SRUID).
225+
226+
Where to specify the namespace, name, and revision tag
227+
------------------------------------------------------
228+
229+
**Namespace**
230+
231+
- Required: yes
232+
- Set in:
233+
234+
- ``octue.yaml``
235+
- ``OCTUE_SERVICE_NAMESPACE`` environment variable (takes priority)
236+
237+
**Name**
238+
239+
- Required: yes
240+
- Set in:
241+
242+
- ``octue.yaml``
243+
- ``OCTUE_SERVICE_NAME`` environment variable (takes priority)
244+
245+
**Revision tag**
246+
247+
- Required: no
248+
- Default: a random "coolname" (e.g. ``hungry-hippo``)
249+
- Set in:
250+
251+
- ``OCTUE_SERVICE_REVISION_TAG`` environment variable
252+
- If using ``octue start`` command, the ``--revision-tag`` option (takes priority)
253+
184254

185255
Template apps
186256
=============

0 commit comments

Comments
 (0)