Skip to content

Commit 37e9251

Browse files
committed
chore: rename flexfun package
- FlexFunctions are now FlexConnect - We will discontinue the old gooddata-flexfun and instead use gooddata-flexconnect - Renamed everything accordingly - There should be no sight of FlexFun anywhere now JIRA: CQ-894 risk: low
1 parent 925e7db commit 37e9251

Some content is hidden

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

65 files changed

+227
-228
lines changed

.envrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export PYTHONPATH="${PYTHONPATH}:${SCRIPT_DIR}/gooddata-api-client/"
99
export PYTHONPATH="${PYTHONPATH}:${SCRIPT_DIR}/gooddata-sdk/"
1010
export PYTHONPATH="${PYTHONPATH}:${SCRIPT_DIR}/gooddata-pandas/"
1111
export PYTHONPATH="${PYTHONPATH}:${SCRIPT_DIR}/gooddata-flight-server/"
12-
export PYTHONPATH="${PYTHONPATH}:${SCRIPT_DIR}/gooddata-flexfun/"
12+
export PYTHONPATH="${PYTHONPATH}:${SCRIPT_DIR}/gooddata-flexconnect/"
1313
export PYTHONPATH="${PYTHONPATH}:${SCRIPT_DIR}/gooddata-dbt/"
1414

1515
export PATH="${PATH}:${SCRIPT_DIR}/gooddata-sdk/bin"

.github/workflows/build-release.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- gooddata-sdk
3030
- gooddata-dbt
3131
- gooddata-flight-server
32-
- gooddata-flexfun
32+
- gooddata-flexconnect
3333
runs-on: ubuntu-latest
3434
steps:
3535
- uses: actions/checkout@v4
@@ -83,7 +83,7 @@ jobs:
8383
- gooddata-sdk
8484
- gooddata-dbt
8585
- gooddata-flight-server
86-
- gooddata-flexfun
86+
- gooddata-flexconnect
8787
steps:
8888
- name: Obtain ${{ matrix.component }} artifacts
8989
uses: actions/download-artifact@v4

.github/workflows/dev-release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- gooddata-sdk
2222
- gooddata-dbt
2323
- gooddata-flight-server
24-
- gooddata-flexfun
24+
- gooddata-flexconnect
2525
steps:
2626
- name: Checkout Repository
2727
uses: actions/checkout@v4

.github/workflows/rw-collect-changes.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
- 'gooddata-api-client/**'
4848
- 'gooddata-dbt/**'
4949
- 'gooddata-flight-server/**'
50-
- 'gooddata-flexfun/**'
50+
- 'gooddata-flexconnect/**'

.github/workflows/rw-python-tests.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
if: ${{ matrix.python_version == 'py312' }}
2525
uses: codecov/codecov-action@v3
2626
with:
27-
files: ./gooddata-sdk/coverage.xml,./gooddata-pandas/coverage.xml,./gooddata-fdw/coverage.xml,./gooddata-flight-server/coverage.xml,./gooddata-flexfun/coverage.xml
27+
files: ./gooddata-sdk/coverage.xml,./gooddata-pandas/coverage.xml,./gooddata-fdw/coverage.xml,./gooddata-flight-server/coverage.xml,./gooddata-flexconnect/coverage.xml
2828
lint-and-format-check:
2929
runs-on: ubuntu-latest
3030
if: ${{inputs.changed-python-modules == 'true'}}

.sonar.settings

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# (C) 2021 GoodData Corporation
2-
sonar.sources=gooddata-sdk,gooddata-fdw,gooddata-pandas,gooddata-flight-server,gooddata-flexfun
2+
sonar.sources=gooddata-sdk,gooddata-fdw,gooddata-pandas,gooddata-flight-server,gooddata-flexconnect
33
sonar.exclusions=gooddata-api-client/**/*
44
sonar.python.version=3.9, 3.10, 3.11, 3.12

.sonarcloud.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# (C) 2022 GoodData Corporation
2-
sonar.sources=gooddata-sdk,gooddata-fdw,gooddata-pandas,gooddata-flight-server,gooddata-flexfun
2+
sonar.sources=gooddata-sdk,gooddata-fdw,gooddata-pandas,gooddata-flight-server,gooddata-flexconnect
33
sonar.exclusions=gooddata-api-client/**/*
44
sonar.python.version=3.9, 3.10, 3.11, 3.12

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ The above copyright notice and this permission notice shall be included in all c
77
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
-----------------------
99

10-
This repository includes source code for gooddata-api-client, gooddata-fdw, gooddata-pandas, gooddata-sdk, gooddata-flight-server, gooddata-flexfun, and gooddata-dbt, each of which is licensed under the MIT license above. For additional licensing information related to open source packages included in each of these projects, please see the OSS LICENSES directory.
10+
This repository includes source code for gooddata-api-client, gooddata-fdw, gooddata-pandas, gooddata-sdk, gooddata-flight-server, gooddata-flexconnect, and gooddata-dbt, each of which is licensed under the MIT license above. For additional licensing information related to open source packages included in each of these projects, please see the OSS LICENSES directory.

dev-requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ pre-commit~=3.8.0
1010
-r ./gooddata-fdw/requirements.txt
1111
-r ./gooddata-dbt/requirements.txt
1212
-r ./gooddata-flight-server/requirements.txt
13-
-r ./gooddata-flexfun/requirements.txt
13+
-r ./gooddata-flexconnect/requirements.txt
1414
-r ./gooddata-sdk/test-requirements.txt
1515
-r ./gooddata-pandas/test-requirements.txt
1616
-r ./gooddata-fdw/test-requirements.txt
1717
-r ./gooddata-dbt/test-requirements.txt
1818
-r ./gooddata-flight-server/test-requirements.txt
19-
-r ./gooddata-flexfun/test-requirements.txt
19+
-r ./gooddata-flexconnect/test-requirements.txt
2020
-r ./tests-support/requirements.txt
File renamed without changes.

gooddata-flexfun/.readthedocs.yaml renamed to gooddata-flexconnect/.readthedocs.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ build:
1212
python: "3.11"
1313

1414
sphinx:
15-
configuration: gooddata-flexfun/docs/conf.py
15+
configuration: gooddata-flexconnect/docs/conf.py
1616

1717
python:
1818
install:
19-
- requirements: gooddata-flexfun/docs/requirements.txt
19+
- requirements: gooddata-flexconnect/docs/requirements.txt
File renamed without changes.
File renamed without changes.

gooddata-flexconnect/README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# GoodData FlexConnect
2+
3+
GoodData FlexConnect allows you to build your own data source for GoodData Cloud or Cloud Native.
4+
5+
FlexConnect works with a concept similar to 'table functions' that you may already know
6+
from database technologies.
7+
8+
- To build your own data source, you implement one or more FlexConnect functions. The
9+
functions compute and return tabular data - how they do it is completely up to you.
10+
- The functions are hosted and invoked inside a FlexConnect server (which is included in this package).
11+
- A running FlexConnect server can be added as a data source to your GoodData Cloud or GoodData Cloud Native.
12+
- The functions available on FlexConnect server will be mapped to data sets within GoodData's Semantic Model
13+
and from then on can be used during report computation.
14+
15+
16+
## Getting Started using the FlexConnect Template
17+
18+
The easiest way to get started writing FlexConnect functions is to use [the template repository](https://github.com/gooddata/gooddata-flexconnect-template).
19+
It provides a simple example of a FlexConnect function that can be used as a starting point for your own FlexConnect functions with all the necessary infrastructure in place.
20+
It also has a README that explains how to get started with the template and some general tips on how to write FlexConnect functions.
21+
22+
## Getting started using the FlexConnect package directly
23+
24+
Install the package alongside the gooddata-flight-server using pip:
25+
26+
```bash
27+
pip install gooddata-flight-server gooddata-flexconnect
28+
```
29+
30+
Next, update the GoodData Flight Server configuration to load the FlexConnect functions.
31+
32+
```toml
33+
[flexconnect]
34+
35+
# specify one or more modules that contain your FlexConnect function implementations
36+
#
37+
functions = [
38+
"flexconnect.your_function"
39+
]
40+
```
41+
42+
Then when running the GoodData Flight Server, use the `--methods-provider` option to load the FlexConnect.
43+
For example:
44+
45+
```bash
46+
#!/bin/bash
47+
48+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
49+
SERVER_CMD="${SCRIPT_DIR}/.venv/bin/gooddata-flight-server"
50+
51+
export PYTHONPATH="${SCRIPT_DIR}/src"
52+
export CONFIG_ENV="${1:-dev}"
53+
54+
$SERVER_CMD start \
55+
--methods-provider gooddata_flexconnect \
56+
--config \
57+
config/${CONFIG_ENV}.server.toml \
58+
config/flexconnect.config.toml \
59+
--logging-config config/default.logging.ini \
60+
--dev-log
61+
```

gooddata-flexfun/gooddata_flexfun/__init__.py renamed to gooddata-flexconnect/gooddata_flexconnect/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# (C) 2024 GoodData Corporation
22

3-
from gooddata_flexfun.flexfun.flex_fun import FlexFun
4-
from gooddata_flexfun.flexfun.flex_fun_execution_context import (
3+
from gooddata_flexconnect.function.execution_context import (
54
ExecutionContext,
65
ExecutionContextAbsoluteDateFilter,
76
ExecutionContextAttribute,
@@ -14,4 +13,5 @@
1413
LabelElementsExecutionRequest,
1514
ReportExecutionRequest,
1615
)
17-
from gooddata_flexfun.flexfun.flight_methods import create_flexfun_flight_methods
16+
from gooddata_flexconnect.function.flight_methods import create_flexconnect_flight_methods
17+
from gooddata_flexconnect.function.function import FlexConnectFunction

gooddata-flexfun/gooddata_flexfun/flexfun/flex_fun_execution_context.py renamed to gooddata-flexconnect/gooddata_flexconnect/function/execution_context.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class ExecutionContextAbsoluteDateFilter:
236236
@dataclass
237237
class ExecutionRequest:
238238
"""
239-
Information about the execution request that is sent to the FlexFun.
239+
Information about the execution request that is sent to the FlexConnect function.
240240
DEPRECATED: Use ReportExecutionRequest instead.
241241
"""
242242

@@ -481,7 +481,7 @@ def _dict_to_attributes(attributes: list[dict]) -> list[ExecutionContextAttribut
481481
@dataclass
482482
class ExecutionContext:
483483
"""
484-
Execution context of the FlexFun
484+
Execution context of the FlexConnect function
485485
"""
486486

487487
execution_type: ExecutionType
@@ -491,17 +491,17 @@ class ExecutionContext:
491491

492492
organization_id: str
493493
"""
494-
The ID of the organization that the FlexFun is executed in.
494+
The ID of the organization that the FlexConnect function is executed in.
495495
"""
496496

497497
workspace_id: str
498498
"""
499-
The ID of the workspace that the FlexFun is executed in.
499+
The ID of the workspace that the FlexConnect function is executed in.
500500
"""
501501

502502
user_id: str
503503
"""
504-
The ID of the user that invoked the FlexFun.
504+
The ID of the user that invoked the FlexConnect function.
505505
"""
506506

507507
timestamp: Optional[str]
@@ -532,13 +532,13 @@ class ExecutionContext:
532532

533533
report_execution_request: Optional[ReportExecutionRequest]
534534
"""
535-
The report execution request that the FlexFun should process.
535+
The report execution request that the FlexConnect function should process.
536536
Only present if the execution type is "REPORT".
537537
"""
538538

539539
label_elements_execution_request: Optional[LabelElementsExecutionRequest]
540540
"""
541-
The label elements execution request that the FlexFun should process.
541+
The label elements execution request that the FlexConnect function should process.
542542
Only present if the execution type is "LABEL_ELEMENTS".
543543
"""
544544

@@ -568,8 +568,9 @@ def from_dict(d: dict) -> "ExecutionContext":
568568
@staticmethod
569569
def from_parameters(parameters: dict) -> Optional["ExecutionContext"]:
570570
"""
571-
Create ExecutionContext from FlexFun parameters.
572-
:param parameters: the parameters dictionary of the FlexFun invocation
571+
Create ExecutionContext from FlexConnect function parameters.
572+
573+
:param parameters: the parameters dictionary of the FlexConnect function invocation
573574
:return: None if the parameters do not contain the execution context, otherwise the execution context
574575
"""
575576
return ExecutionContext.from_dict(parameters["executionContext"]) if "executionContext" in parameters else None

gooddata-flexfun/gooddata_flexfun/flexfun/flight_methods.py renamed to gooddata-flexconnect/gooddata_flexconnect/function/flight_methods.py

+31-28
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
flight_server_methods,
1717
)
1818

19-
from gooddata_flexfun.flexfun.flex_fun import FlexFun
20-
from gooddata_flexfun.flexfun.flex_fun_registry import FlexFunRegistry
21-
from gooddata_flexfun.flexfun.flex_fun_task import FlexFunTask
19+
from gooddata_flexconnect.function.function import FlexConnectFunction
20+
from gooddata_flexconnect.function.function_registry import FlexConnectFunctionRegistry
21+
from gooddata_flexconnect.function.function_task import FlexConnectFunctionTask
2222

23-
_LOGGER = structlog.get_logger("gooddata_flexfun.rpc")
23+
_LOGGER = structlog.get_logger("gooddata_flexconnect.rpc")
2424
_DEFAULT_TASK_WAIT = 60.0
2525

2626

27-
class _FlexFunServerMethods(FlightServerMethods):
28-
def __init__(self, ctx: ServerContext, registry: FlexFunRegistry) -> None:
27+
class _FlexConnectServerMethods(FlightServerMethods):
28+
def __init__(self, ctx: ServerContext, registry: FlexConnectFunctionRegistry) -> None:
2929
self._ctx = ctx
3030
self._registry = registry
3131

@@ -38,7 +38,7 @@ def _create_descriptor(fun_name: str, metadata: Optional[dict]) -> pyarrow.fligh
3838

3939
return pyarrow.flight.FlightDescriptor.for_command(orjson.dumps(cmd))
4040

41-
def _create_fun_info(self, fun: type[FlexFun]) -> pyarrow.flight.FlightInfo:
41+
def _create_fun_info(self, fun: type[FlexConnectFunction]) -> pyarrow.flight.FlightInfo:
4242
# these are for type checker; the registry will only register functions
4343
# that have proper metadata on them
4444
assert fun.Name is not None
@@ -57,18 +57,21 @@ def _extract_invocation_payload(
5757
) -> tuple[str, dict, Optional[tuple[str, ...]]]:
5858
if descriptor.command is None or not len(descriptor.command):
5959
raise ErrorInfo.bad_argument(
60-
"Incorrect FlexFun invocation. Flight descriptor must contain command with the invocation payload."
60+
"Incorrect FlexConnect function invocation. Flight descriptor must contain command "
61+
"with the invocation payload."
6162
)
6263

6364
try:
6465
payload = orjson.loads(descriptor.command)
6566
except Exception:
66-
raise ErrorInfo.bad_argument("Incorrect FlexFun invocation. The invocation payload is not a valid JSON.")
67+
raise ErrorInfo.bad_argument(
68+
"Incorrect FlexConnect function invocation. The invocation payload is " "not a valid JSON."
69+
)
6770

6871
fun = payload.get("functionName")
6972
if fun is None or not len(fun):
7073
raise ErrorInfo.bad_argument(
71-
"Incorrect FlexFun invocation. The invocation payload does not specify 'functionName'."
74+
"Incorrect FlexConnect function invocation. The invocation payload does not specify 'functionName'."
7275
)
7376

7477
parameters = payload.get("parameters") or {}
@@ -80,13 +83,13 @@ def _prepare_task(
8083
self,
8184
context: pyarrow.flight.ServerCallContext,
8285
descriptor: pyarrow.flight.FlightDescriptor,
83-
) -> FlexFunTask:
86+
) -> FlexConnectFunctionTask:
8487
fun_name, parameters, columns = self._extract_invocation_payload(descriptor)
8588
headers = self.call_info_middleware(context).headers
86-
flex_fun = self._registry.create_function(fun_name)
89+
fun = self._registry.create_function(fun_name)
8790

88-
return FlexFunTask(
89-
fun=flex_fun,
91+
return FlexConnectFunctionTask(
92+
fun=fun,
9093
parameters=parameters,
9194
columns=columns,
9295
headers=headers,
@@ -100,7 +103,7 @@ def _prepare_flight_info(self, task_result: TaskExecutionResult) -> pyarrow.flig
100103
if task_result.cancelled:
101104
raise ErrorInfo.for_reason(
102105
ErrorCode.COMMAND_CANCELLED,
103-
f"FlexFun invocation was cancelled. Invocation task was: '{task_result.task_id}'.",
106+
f"FlexConnect function invocation was cancelled. Invocation task was: '{task_result.task_id}'.",
104107
).to_server_error()
105108

106109
result = task_result.result
@@ -127,17 +130,17 @@ def list_flights(
127130
self, context: pyarrow.flight.ServerCallContext, criteria: bytes
128131
) -> Generator[pyarrow.flight.FlightInfo, None, None]:
129132
structlog.contextvars.bind_contextvars(peer=context.peer())
130-
_LOGGER.info("list_flights", available_funs=self._registry.flex_funs_names)
133+
_LOGGER.info("list_flights", available_funs=self._registry.function_names)
131134

132-
return (self._create_fun_info(fun) for fun in self._registry.flex_funs.values())
135+
return (self._create_fun_info(fun) for fun in self._registry.functions.values())
133136

134137
def get_flight_info(
135138
self,
136139
context: pyarrow.flight.ServerCallContext,
137140
descriptor: pyarrow.flight.FlightDescriptor,
138141
) -> pyarrow.flight.FlightInfo:
139142
structlog.contextvars.bind_contextvars(peer=context.peer())
140-
task: Optional[FlexFunTask] = None
143+
task: Optional[FlexConnectFunctionTask] = None
141144

142145
try:
143146
task = self._prepare_task(context, descriptor)
@@ -163,7 +166,7 @@ def get_flight_info(
163166
if task is not None:
164167
_LOGGER.error("get_flight_info_failed", task_id=task.task_id, fun=task.fun_name, exc_info=True)
165168
else:
166-
_LOGGER.error("flexfun_submit_failed", exc_info=True)
169+
_LOGGER.error("flexconnect_fun_submit_failed", exc_info=True)
167170

168171
raise
169172

@@ -190,23 +193,23 @@ def do_get(
190193
raise
191194

192195

193-
_FLEXFUN_CONFIG_SECTION = "flexfun"
194-
_FLEXFUN_FUNCTION_LIST = "functions"
196+
_FLEX_CONNECT_CONFIG_SECTION = "flexconnect"
197+
_FLEX_CONNECT_FUNCTION_LIST = "functions"
195198

196199

197200
@flight_server_methods
198-
def create_flexfun_flight_methods(ctx: ServerContext) -> FlightServerMethods:
201+
def create_flexconnect_flight_methods(ctx: ServerContext) -> FlightServerMethods:
199202
"""
200-
This factory creates implementation of Flight RPC methods that realize the FlexFun server.
203+
This factory creates implementation of Flight RPC methods that realize the FlexConnect server.
201204
202-
FlexFun Server hosts one or more functions developed externally, and linked to the server
205+
FlexConnect Server hosts one or more functions developed externally, and linked to the server
203206
at runtime - during startup.
204207
205208
:param ctx: server's context
206209
:return: new instance of Flight RPC server methods to integrate into the server
207210
"""
208-
modules = list(ctx.settings.get(f"{_FLEXFUN_CONFIG_SECTION}.{_FLEXFUN_FUNCTION_LIST}") or [])
209-
_LOGGER.info("flexfun_init", modules=modules)
210-
registry = FlexFunRegistry().load(ctx, modules)
211+
modules = list(ctx.settings.get(f"{_FLEX_CONNECT_CONFIG_SECTION}.{_FLEX_CONNECT_FUNCTION_LIST}") or [])
212+
_LOGGER.info("flexconnect_init", modules=modules)
213+
registry = FlexConnectFunctionRegistry().load(ctx, modules)
211214

212-
return _FlexFunServerMethods(ctx, registry)
215+
return _FlexConnectServerMethods(ctx, registry)

0 commit comments

Comments
 (0)