[
https://issues.apache.org/jira/browse/FLINK-22728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17348924#comment-17348924
]
Dian Fu commented on FLINK-22728:
---------------------------------
[~JYXL_1] You could take a look at the following:
[https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/dev/python/faq/#adding-python-files]
If it still doesn't solve your problem, you need provide more information:
- How you import MyKeySelector in your main_task.py?
- How you specify the dependency in `env.add_python_file`? It would be great
to provide some code snippet.
> a problem of loading udf
> ------------------------
>
> Key: FLINK-22728
> URL: https://issues.apache.org/jira/browse/FLINK-22728
> Project: Flink
> Issue Type: Bug
> Components: API / Python
> Affects Versions: 1.13.0
> Environment: python3.7
> centos 8
> pyflink1.13.0
> java1.11
> Reporter: JYXL
> Priority: Major
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> hi:
> I'm using the stream udf by python.
> udf as bellow:
>
> class MyKeySelector(KeySelector):
> def __init__(self, partitions: int=6):
> self.partitions = partitions
> def get_key(self, value):
> return random.randint(0, self.partitions)
>
> when I code it with the main task in the same script, it works,
> but when I make it in a simgle script, it cannot work.
> the archives as bellow:
>
> project:
> | __init__.py
> | key_function.py
> | main_task.py
>
> I'm confused when I use env.add_python_file method, it cannot work either,
> no matter the parameter `file_path` is '~/project' or
> '~/project/key_function.py.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)