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.

Add default 'aws_conn_id' to SageMaker Operators

See original GitHub issue

The SageMaker Operators not having a default value for aws_conn_id is a pain, we should fix that. See EKS operators for an example: https://github.com/apache/airflow/blob/main/airflow/providers/amazon/aws/operators/eks.py

_Originally posted by @ferruzzi in https://github.com/apache/airflow/pull/21673#discussion_r813414043_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
hsrockscommented, Mar 4, 2022

Got the intent . Yes can see this problem with few of them individually . Appreciate the details 😃 Will work this out.!!

1reaction
ferruzzicommented, Mar 4, 2022

The problem is that the individual operators also declare the aws_conn without a default value so it isn’t optional, and it won’t fall back to that value:

In [1]: class Foo():
   ...:     def __init__(self, myvar=5):
   ...:         self.myvar = myvar
   ...: 
   ...:     def op(self):
   ...:         return self.myvar
   ...: 
   ...: class Bar(Foo):
   ...:     def __init__(self, myvar):
   ...:         super().__init__(myvar=myvar)
   ...: 

In [2]: Foo().op()
Out[2]: 5

In [3]: Foo(3).op()
Out[3]: 3

In [4]: Bar(2).op()
Out[4]: 2

In [5]: Bar().op()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-06b11a1ebf4e> in <module>
----> 1 Bar().op()

TypeError: __init__() missing 1 required positional argument: 'myvar'

So if we move the defaulting into the child Operators, we don’t have to declare aws_conn_id='default_aws' in every operator use:

In [1]: class Foo:
   ...:     def __init__(self):
   ...:         pass
   ...: 
   ...:     def op(self):
   ...:         return self.myvar
   ...: 
   ...: 
   ...: class Bar(Foo):
   ...:     def __init__(self, myvar=5):
   ...:         self.myvar = myvar
   ...:         super().__init__()
   ...: 

In [2]: Bar(2).op()
Out[2]: 2

In [3]: Bar().op()
Out[3]: 5
Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with permissions in Amazon Managed Workflows for ...
In this post I will be covering Part 2, how to ensure that you control access to Apache Airflow following best practices such...
Read more >
Working with permissions in Amazon Managed ... - DevPress
In this post I will be covering Part 2, how to ensure that you control access to Apache Airflow following best practices such...
Read more >
airflow.exceptions.AirflowException Example - Program Talk
Wraps a function into an Airflow operator. ... Defaults to False. ... Optional[Set] = None, ): """ Check status of a SageMaker job...
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