Skip to content

Commit

Permalink
FIX: Remove special treatment of latest revision tag
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Using the `latest` tag for a service will now only
work if an explicit tag with that name has been set. To get the default
service revision, just omit the revision tag entirely.
  • Loading branch information
cortadocodes committed Jul 13, 2023
1 parent 622dd2c commit 2d00327
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 42 deletions.
14 changes: 1 addition & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,7 @@ repos:
- id: check-branch-name
args:
- "^main$"
- "^development$"
- "^devops/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^doc/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^feature/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^enhancement/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^fix/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^hotfix/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^review/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^refactor/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^test/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^style/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^deprecation/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^dependencies/([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
- "^([a-z][a-z0-9]*)(-[a-z0-9]+)*$"

- repo: https://github.com/octue/conventional-commits
rev: 0.9.0
Expand Down
28 changes: 14 additions & 14 deletions docs/source/asking_questions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and/or an input manifest.
from octue.resources import Child
child = Child(
id="my-organisation/my-service:latest",
id="my-organisation/my-service:2.1.7",
backend={"name": "GCPPubSubBackend", "project_name": "my-project"},
)
Expand All @@ -31,15 +31,15 @@ and/or an input manifest.
>>> <FilterSet({<Datafile('my_file.csv')>, <Datafile('another_file.csv')>})>
.. _using_latest_revision_tag:
.. _using_default_revision_tag:

.. note::

Using the ``latest`` service revision tag, or not including one at all, will cause your question to be sent to the
latest deployed revision of the service. This is determined by making a request to a `service registry
<https://django-twined.readthedocs.io/en/latest/>`_ if one or more :ref:`registries are defined
<using_service_registries>`. If none of the service registries contain an entry for this service, a specific service
revision tag must be used.
Not including a service revision tag will cause your question to be sent to the default revision of the service (
usually the latest deployed version). This is determined by making a request to a `service registry
<https://django-twined.readthedocs.io/en/latest/>`_ if one or more
:ref:`registries are defined <using_service_registries>`. If none of the service registries contain an entry for
this service, a specific service revision tag must be used.

You can also set the following options when you call :mod:`Child.ask <octue.resources.child.Child.ask>`:

Expand Down Expand Up @@ -100,15 +100,15 @@ if your app configuration file is:
"children": [
{
"key": "wind_speed",
"id": "template-child-services/wind-speed-service:latest",
"id": "template-child-services/wind-speed-service:2.1.1",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "my-project"
}
},
{
"key": "elevation",
"id": "template-child-services/elevation-service:latest",
"id": "template-child-services/elevation-service:3.1.9",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "my-project"
Expand Down Expand Up @@ -161,15 +161,15 @@ For example, if the child requires these children in its app configuration:
[
{
"key": "wind_speed",
"id": "template-child-services/wind-speed-service:latest",
"id": "template-child-services/wind-speed-service:2.1.1",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "octue-sdk-python"
},
},
{
"key": "elevation",
"id": "template-child-services/elevation-service:latest",
"id": "template-child-services/elevation-service:3.1.9",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "octue-sdk-python"
Expand All @@ -186,15 +186,15 @@ then you can override them like this:
children=[
{
"key": "wind_speed",
"id": "my/own-service:latest",
"id": "my/own-service:1.0.0",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "octue-sdk-python"
},
},
{
"key": "elevation",
"id": "organisation/another-service:latest",
"id": "organisation/another-service:0.1.0",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "octue-sdk-python"
Expand Down Expand Up @@ -244,7 +244,7 @@ You can specify service registries in two ways:
.. code-block:: python
child = Child(
id="my-organisation/my-service:latest",
id="my-organisation/my-service:1.1.0",
backend={"name": "GCPPubSubBackend", "project_name": "my-project"},
service_registries=[
{"name": "my-registry", "endpoint": "blah.com/services"},
Expand Down
2 changes: 1 addition & 1 deletion docs/source/manifest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Get an Octue service to analyse data for you as part of a larger analysis.
from octue.resources import Child
child = Child(
id="octue/wind-speed:latest",
id="octue/wind-speed:2.1.0",
backend={"name": "GCPPubSubBackend", "project_name": "my-project"},
)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ They look like ``namespace/name:tag`` where the tag is often a semantic version
The SRUID is a special case of a service ID. A service ID can be an SRUID or just the service namespace and
name. It can be used to ask a question to a service without specifying a specific revision of it. This enables
asking questions to, for example, the service ``octue/my-service`` and automatically having them routed to its
latest revision. :ref:`See here for more info<using_latest_revision_tag>`.
default (usually latest) revision. :ref:`See here for more info<using_default_revision_tag>`.
10 changes: 5 additions & 5 deletions docs/source/testing_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ To emulate your children in tests, patch the :mod:`Child <octue.resources.child.
children = [
{
"key": "my_child",
"id": "octue/my-child-service:latest",
"id": "octue/my-child-service:2.1.0",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "my-project"
Expand All @@ -172,13 +172,13 @@ To emulate your children in tests, patch the :mod:`Child <octue.resources.child.
app_src=app_directory_path,
twine=os.path.join(app_directory_path, "twine.json"),
children=children,
service_id="your-org/your-service:latest",
service_id="your-org/your-service:2.1.0",
)
emulated_children = [
ChildEmulator(
id="octue/my-child-service:latest",
internal_service_name="you/your-service:latest",
id="octue/my-child-service:2.1.0",
internal_service_name="you/your-service:2.1.0",
messages=[
{
"type": "result",
Expand Down Expand Up @@ -222,7 +222,7 @@ child.
child = Child(
id="octue/my-child:latest",
id="octue/my-child:2.1.0",
backend={"name": "GCPPubSubBackend", "project_name": "my-project"},
)
Expand Down
8 changes: 4 additions & 4 deletions docs/source/troubleshooting_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ your service to fail.
children = [
{
"key": "my_child",
"id": "octue/my-child-service:latest",
"id": "octue/my-child-service:2.1.0",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "my-project",
}
},
{
"key": "another_child",
"id": "octue/another-child-service:latest",
"id": "octue/another-child-service:2.1.0",
"backend": {
"name": "GCPPubSubBackend",
"project_name": "my-project",
Expand All @@ -101,7 +101,7 @@ your service to fail.
children=children,
configuration_values=configuration_values,
configuration_manifest=configuration_manifest,
service_id="your-org/your-service:latest",
service_id="your-org/your-service:2.1.0",
)
with patch("octue.runner.Child", side_effect=child_emulators):
Expand All @@ -117,7 +117,7 @@ For example:
.. code-block:: python
child = Child(
id="my-organisation/my-service:latest",
id="my-organisation/my-service:2.1.0",
backend={"name": "GCPPubSubBackend", "project_name": "my-project"},
)
Expand Down
2 changes: 1 addition & 1 deletion octue/cloud/pub_sub/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def ask(
"""
service_namespace, service_name, service_revision_tag = split_service_id(service_id)

if not service_revision_tag or service_revision_tag == "latest":
if not service_revision_tag:
service_id = get_latest_sruid(
namespace=service_namespace,
name=service_name,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "octue"
version = "0.47.2"
version = "0.48.0"
description = "A package providing template applications for data services, and a python SDK to the Octue API."
readme = "README.md"
authors = ["Marcus Lugg <marcus@octue.com>", "Thomas Clark <support@octue.com>"]
Expand Down
4 changes: 2 additions & 2 deletions tests/cloud/pub_sub/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def test_repr(self):

def test_repr_with_name(self):
"""Test that services are represented using their name if they have one."""
service = Service(backend=BACKEND, name="octue/blah-service:latest")
self.assertEqual(repr(service), "<Service('octue/blah-service:latest')>")
service = Service(backend=BACKEND, name=f"octue/blah-service:{MOCK_SERVICE_REVISION_TAG}")
self.assertEqual(repr(service), f"<Service('octue/blah-service:{MOCK_SERVICE_REVISION_TAG}')>")

def test_service_id_cannot_be_non_none_empty_value(self):
"""Ensure that a ValueError is raised if a non-None empty value is provided as the service_id."""
Expand Down

0 comments on commit 2d00327

Please sign in to comment.