Skip to content

Commit 91517c5

Browse files
committed
py: warn if the client and server versions do not match
Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
1 parent eb55f4d commit 91517c5

4 files changed

Lines changed: 42 additions & 22 deletions

File tree

python/feldera/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from feldera.rest.feldera_client import FelderaClient as FelderaClient
22
from feldera.pipeline import Pipeline as Pipeline
33
from feldera.pipeline_builder import PipelineBuilder as PipelineBuilder
4+
from feldera.rest._helpers import client_version
5+
6+
__version__ = client_version()
47

58
import pretty_errors
69

python/feldera/enums.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,28 @@ class BuildMode(Enum):
3636

3737
class PipelineStatus(Enum):
3838
"""
39-
Represents the state that this pipeline is currently in.
40-
41-
.. code-block:: text
42-
43-
Stopped ◄─────────── Stopping ◄───── All states can transition
44-
│ ▲ to Stopping by either:
45-
/start or /pause │ │ (1) user calling /stop?force=true, or;
46-
▼ │ (2) pipeline encountering a fatal
47-
⌛Provisioning Suspending resource or runtime error,
48-
│ ▲ having the system call /stop?force=true
49-
▼ │ /stop effectively
50-
⌛Initializing ─────────────┤ ?force=false
51-
│ │
52-
┌─────────┼────────────────────┴─────┐
53-
│ ▼ │
54-
│ Paused ◄──────► Unavailable │
55-
│ │ ▲ ▲ │
56-
│ /start │ │ /pause │ │
57-
│ ▼ │ │ │
58-
│ Running ◄─────────────┘ │
59-
└────────────────────────────────────┘
39+
Represents the state that this pipeline is currently in.
40+
41+
.. code-block:: text
42+
43+
Stopped ◄─────────── Stopping ◄───── All states can transition
44+
│ ▲ to Stopping by either:
45+
/start or /pause │ │ (1) user calling /stop?force=true, or;
46+
▼ │ (2) pipeline encountering a fatal
47+
⌛Provisioning Suspending resource or runtime error,
48+
│ ▲ having the system call /stop?force=true
49+
▼ │ /stop effectively
50+
⌛Initializing ─────────────┤ ?force=false
51+
│ │
52+
┌─────────┼────────────────────┴─────┐
53+
│ ▼ │
54+
│ Paused ◄──────► Unavailable │
55+
│ │ ▲ ▲ │
56+
│ /start │ │ /pause │ │
57+
│ ▼ │ │ │
58+
│ Running ◄─────────────┘ │
59+
└────────────────────────────────────┘
60+
6061
"""
6162

6263
NOT_FOUND = 0

python/feldera/rest/_helpers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def client_version() -> str:
2+
from importlib.metadata import version, PackageNotFoundError
3+
4+
try:
5+
version = version("feldera")
6+
except PackageNotFoundError:
7+
version = "unknown"
8+
9+
return version

python/feldera/rest/feldera_client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from feldera.rest.errors import FelderaTimeoutError
1212
from feldera.rest.pipeline import Pipeline
1313
from feldera.rest._httprequests import HttpRequests
14+
from feldera.rest._helpers import client_version
1415

1516

1617
def _validate_no_none_keys_in_map(data):
@@ -63,7 +64,13 @@ def __init__(
6364
self.http = HttpRequests(self.config)
6465

6566
try:
66-
self.pipelines()
67+
config = self.get_config()
68+
version = client_version()
69+
if config.version != version:
70+
logging.warn(
71+
f"Client is on version {version} while server is at "
72+
f"{config.version}. There could be incompatibilities."
73+
)
6774
except Exception as e:
6875
logging.error(f"Failed to connect to Feldera API: {e}")
6976
raise e

0 commit comments

Comments
 (0)