You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "tnyz (via GitHub)" <gi...@apache.org> on 2023/09/27 20:46:35 UTC
[GitHub] [airflow] tnyz opened a new pull request, #34654: Remove required emr serverless operator param
tnyz opened a new pull request, #34654:
URL: https://github.com/apache/airflow/pull/34654
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
as best practice users should be able to provision their serverless app using the config api without having to define/duplicate job type and release version in the airflow abstration
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Taragolis commented on pull request #34654: Remove required emr serverless operator param
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #34654:
URL: https://github.com/apache/airflow/pull/34654#issuecomment-1739690084
@tnyz in this case you might utilize [Default Arguments](https://airflow.apache.org/docs/apache-airflow/stable/tutorial/fundamentals.html#default-arguments) feature, and task arguments assignment order described in [Tasks](https://airflow.apache.org/docs/apache-airflow/stable/tutorial/fundamentals.html#tasks)
```python
import pendulum
from airflow.models.dag import DAG
from airflow.providers.amazon.aws.operators.emr import EmrServerlessCreateApplicationOperator
default_args = {
# same as arguments name in operators
"job_type": "BAZ",
"release_label": "QUX"
}
with DAG(dag_id="foo_bar", start_date=pendulum.DateTime(2021, 1, 1), catchup=False, default_args=default_args):
# Static Checkers might complain about this, but it would work if you assigned tasks into the DAG or TaskGroup context
task = EmrServerlessCreateApplicationOperator(task_id="spam")
task2 = EmrServerlessCreateApplicationOperator(task_id="egg", job_type="some-job-type")
# Just for check that it assigned, no need to be defined in real DAG
assert task.job_type == "BAZ"
assert task.release_label == "QUX"
assert task2.job_type == "some-job-type"
assert task2.release_label == "QUX"
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] tnyz commented on pull request #34654: Remove required emr serverless operator param
Posted by "tnyz (via GitHub)" <gi...@apache.org>.
tnyz commented on PR #34654:
URL: https://github.com/apache/airflow/pull/34654#issuecomment-1738115366
>Optional dictionary for arbitrary parameters to the boto API create_application call.
so I think this statement is not accurate as you cannot put release_version in this dictionary. should we change the doc string instead?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] tnyz commented on pull request #34654: Remove required emr serverless operator param
Posted by "tnyz (via GitHub)" <gi...@apache.org>.
tnyz commented on PR #34654:
URL: https://github.com/apache/airflow/pull/34654#issuecomment-1739607537
thanks, I think I will leave it as is for now
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Taragolis commented on pull request #34654: Remove required emr serverless operator param
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #34654:
URL: https://github.com/apache/airflow/pull/34654#issuecomment-1738094904
Could you add a bit more details about this best practices?
Unfortunately I can’t find any info, according to the [boto3 doc](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/emr-serverless/client/create_application.html) this fields are mandatory, in some cases it doesn’t mean that it actually mandatory 🤣
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] tnyz closed pull request #34654: Remove required emr serverless operator param
Posted by "tnyz (via GitHub)" <gi...@apache.org>.
tnyz closed pull request #34654: Remove required emr serverless operator param
URL: https://github.com/apache/airflow/pull/34654
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] tnyz commented on pull request #34654: Remove required emr serverless operator param
Posted by "tnyz (via GitHub)" <gi...@apache.org>.
tnyz commented on PR #34654:
URL: https://github.com/apache/airflow/pull/34654#issuecomment-1738107974
> Could you add a bit more details about this best practices? Unfortunately I can’t find any info, according to the [boto3 doc](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/emr-serverless/client/create_application.html) this fields are mandatory, in some cases it doesn’t mean that it actually mandatory 🤣
ok I think I understand what you meant. yes it seems like they are mandatory therefore they are part of operator param. this is definitely an interesting approach as I always thought these are supposed to be validated on the server side not by airflow operator api
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Taragolis commented on pull request #34654: Remove required emr serverless operator param
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #34654:
URL: https://github.com/apache/airflow/pull/34654#issuecomment-1738828125
> this is definitely an interesting approach as I always thought these are supposed to be validated on the server side not by airflow operator api
I'm not sure that there is exists rule where validation should happen, in general speaking it might be done in different parts:
- Mandatory fields in operator. User will get an error during DAG creation.
- In init method. User will get an error during DAG creation. However it is not recommended way because it prevent to make this attribute templated
- Somewhere execute method. User will get an error during Task execution
- Keep validation for upstream library. User will get an error during Task execution
In additional, in some circumstances `botocore` might check parameters before send request to server, as well as propagate default values for required fields but that is internals of `botocore` / `boto3` (aka mysterious box)
> so I think this statement is not accurate as you cannot put release_version in this dictionary. should we change the doc string instead?
Yes, it will raise `TypeError: create_application() got multiple values for argument 'releaseLabel'` in
https://github.com/apache/airflow/blob/f12ed1edc64021b603208fd87a05635f9adcfbe4/airflow/providers/amazon/aws/operators/emr.py#L1061-L1066
So if you want to have ability to provide this parameters as part of `config` argument you need to resolve it before, for example create parameters dict before, e.g. something like that
```python
create_application_params = {
"clientToken": self.client_request_token,
"releaseLabel": self.release_label,
"type": self.job_type,
**self.config,
}
response = self.hook.conn.create_application(**create_application_params)
```
And in additional it required to add tests cases as well as information either in docstring or in [operator documentation](https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/operators/emr/emr_serverless.html#create-an-emr-serverless-application)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org