question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom operator name field dont accept special characters

See original GitHub issue

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 :

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 = my_operator_param
    super(DevMultiplyoperator, self).__init__( * args, ** kwargs)
  
  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]

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ashbcommented, Nov 28, 2020

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?

0reactions
ashbcommented, Feb 25, 2021

Closing due to no response. We can reopen this if we get more details.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to not allow user to give special characters, numbers ...
Save this answer. Show activity on this post. You can try the carrot symbol in regex -> Something like /^[A-Za-z]/ -> this will...
Read more >
Should we allow special characters or numbers in name field?
Yes you should! Your suggestion about having a validation rule would be a very bad idea. Did you know, the world's most common...
Read more >
Errors using special characters in Access databases - Office
Lists the special characters to avoid using when you work with the database object names or the field names in all versions of...
Read more >
Using Special Characters in Queries - Coveo Documentation
When two equal characters appear between a field name and its argument, these equal signs act as an exact, contiguous, and same order...
Read more >
How to delete special / unwanted characters in Excel - Ablebits
See how to strip special characters from a text string using Excel formulas and remove unwanted characters from multiple cells with custom ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found