You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/07/15 18:39:15 UTC
[GitHub] [airflow] aladinoss opened a new issue #9840: Custom operator field name field dont accept special characters
aladinoss opened a new issue #9840:
URL: https://github.com/apache/airflow/issues/9840
**Apache Airflow version**: 1.10.2 --> 1.10.11
**Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
**Environment**:
- **Cloud provider or hardware configuration**: Internal Cloud solution (VM hosting)
- **OS** (e.g. from /etc/os-release): rhel 7.7
- **Kernel** (e.g. `uname -a`): any
- **Install tools**: pypi
- **Others**:
**What happened**:
Cant import operator if name field contains special or caps character
**What you expected to happen**:
Load the operator even name contains special character
**How to reproduce it**:
just add special or caps characters to the class field name
example :
```python
import logging
from airflow.models import BaseOperator
from airflow.plugins_manager import Airflowplugin
from airflow.utils.decorators import apply_defaults
log = logging.getLogger(__name__)
class DevMultiplyOperator(BaseOperator):
@apply_defaults
def __init__(self, my_operator_param, * args, ** kwargs):
self.operator param = myoperator param
super(DevMultiplyoperator, self).__init__( * args, ** kwargs)
def execute(self, context):
try:
log.info operator param: % 5 ', self.operator param)
if not isinstance(self.operator_param, int): raise TypeError('Use integer as inputs.)
return (self.operator param * 5)
except Exception as error:
log.error(error)
raise
class Dex Multiple plugin(Airflow Plugin):
name = "dev_multiply_plugin"
operators = [DevMultiplyoperator]
```
**Anything else we need to know**:
We are using plugins directory to host operators/hooks/sensor to better organize project.
/dags --> contains dags and subdags
/plugins --> contains operators/hooks/sensor
/config --> contains configuration files
/tests --> contains tests files
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb commented on issue #9840: Custom operator name field dont accept special characters
Posted by GitBox <gi...@apache.org>.
ashb commented on issue #9840:
URL: https://github.com/apache/airflow/issues/9840#issuecomment-785831246
Closing due to no response. We can reopen this if we get more details.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ephraimbuddy commented on issue #9840: Custom operator name field dont accept special characters
Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on issue #9840:
URL: https://github.com/apache/airflow/issues/9840#issuecomment-659278958
It seems that you are not using super correctly. Can you change the way you are using it?
Change this
``` super(DevMultiplyoperator, self).__init__( * args, ** kwargs)```
to
``` super().__init__( * args, ** kwargs)```
Before initializing your parameters.
```
import logging
from airflow.models import BaseOperator
from airflow.plugins_manager import Airflowplugin
from airflow.utils.decorators import apply_defaults
log = logging.getLogger(__name__)
class DevMultiplyOperator(BaseOperator):
@apply_defaults
def __init__(self, my_operator_param, * args, ** kwargs):
super().__init__( * args, ** kwargs)
self.operator_param = my_operator_param
def execute(self, context):
try:
log.info('operator_param: %s', self.operator_param)
if not isinstance(self.operator_param, int):
raise TypeError('Use integer as inputs.')
return (self.operator_param * 5)
except Exception as error:
log.error(error)
raise
class DevMultiplyPlugin(AirflowPlugin):
name = "dev_multiply_plugin"
operators = [DevMultiplyoperator]
```
I didn't try this but that's how most operators in airflow are designed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on issue #9840: Custom operator field name field dont accept special characters
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #9840:
URL: https://github.com/apache/airflow/issues/9840#issuecomment-658935226
Thanks for opening your first issue here! Be sure to follow the issue template!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb commented on issue #9840: Custom operator name field dont accept special characters
Posted by GitBox <gi...@apache.org>.
ashb commented on issue #9840:
URL: https://github.com/apache/airflow/issues/9840#issuecomment-735291406
> It seems that you are not using super correctly. Can you change the way you are using it?
> Change this
> ` super(DevMultiplyoperator, self).__init__( * args, ** kwargs)`
> to
> ` super().__init__( * args, ** kwargs)`
@ephraimbuddy That is Python2 vs Python3 syntax. Airflow code base has switched to the later, but the former will still work on Python3 without trouble, so it's not that.
@aladinoss How were you trying to import this? What error did you receive when you did so?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] aladinoss commented on issue #9840: Custom operator name field dont accept special characters
Posted by GitBox <gi...@apache.org>.
aladinoss commented on issue #9840:
URL: https://github.com/apache/airflow/issues/9840#issuecomment-739441942
Thanks,
i'll check next week, provide you more details.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ashb closed issue #9840: Custom operator name field dont accept special characters
Posted by GitBox <gi...@apache.org>.
ashb closed issue #9840:
URL: https://github.com/apache/airflow/issues/9840
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on issue #9840: Custom operator name field dont accept special characters
Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #9840:
URL: https://github.com/apache/airflow/issues/9840#issuecomment-658982039
Will take a look at it shortly @aladinoss :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org