Re: [PR] Add AWS SageMaker Unified Studio Notebook Operator [airflow]

2025-01-28 Thread via GitHub


o-nikolas commented on code in PR #45726:
URL: https://github.com/apache/airflow/pull/45726#discussion_r1919248414


##
providers/src/airflow/providers/amazon/aws/hooks/sagemaker_unified_studio.py:
##
@@ -0,0 +1,185 @@
+# 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.
+
+"""This module contains the Amazon SageMaker Unified Studio Notebook hook."""
+
+import time
+
+from airflow import AirflowException
+from airflow.hooks.base import BaseHook
+from sagemaker_studio import ClientConfig
+from sagemaker_studio._openapi.models import GetExecutionRequest, 
StartExecutionRequest
+from sagemaker_studio.sagemaker_studio_api import SageMakerStudioAPI
+
+from airflow.providers.amazon.aws.utils.sagemaker_unified_studio import 
is_local_runner
+
+
+class SageMakerNotebookHook(BaseHook):
+"""
+Interact with the Sagemaker Workflows API.
+
+This hook provides a wrapper around the Sagemaker Workflows Notebook 
Execution API.
+
+Examples:
+ .. code-block:: python
+
+from workflows.airflow.providers.amazon.aws.hooks.notebook_hook import 
NotebookHook
+
+notebook_hook = NotebookHook(
+input_config={'input_path': 'path/to/notebook.ipynb', 
'input_params': {'param1': 'value1'}},
+output_config={'output_uri': 'folder/output/location/prefix', 
'output_format': 'ipynb'},
+execution_name='notebook_execution',
+poll_interval=10,
+)
+:param execution_name: The name of the notebook job to be executed, this 
is same as task_id.
+:param input_config: Configuration for the input file.
+Example: {'input_path': 'folder/input/notebook.ipynb', 'input_params': 
{'param1': 'value1'}}
+:param output_config: Configuration for the output format. It should 
include an output_formats parameter to control

Review Comment:
   This sentence seems to just tail off in the middle?



##
providers/src/airflow/providers/amazon/aws/hooks/sagemaker_unified_studio.py:
##
@@ -0,0 +1,185 @@
+# 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.
+
+"""This module contains the Amazon SageMaker Unified Studio Notebook hook."""
+
+import time
+
+from airflow import AirflowException
+from airflow.hooks.base import BaseHook
+from sagemaker_studio import ClientConfig
+from sagemaker_studio._openapi.models import GetExecutionRequest, 
StartExecutionRequest
+from sagemaker_studio.sagemaker_studio_api import SageMakerStudioAPI
+
+from airflow.providers.amazon.aws.utils.sagemaker_unified_studio import 
is_local_runner
+
+
+class SageMakerNotebookHook(BaseHook):
+"""
+Interact with the Sagemaker Workflows API.
+
+This hook provides a wrapper around the Sagemaker Workflows Notebook 
Execution API.
+
+Examples:
+ .. code-block:: python
+
+from workflows.airflow.providers.amazon.aws.hooks.notebook_hook import 
NotebookHook
+
+notebook_hook = NotebookHook(
+input_config={'input_path': 'path/to/notebook.ipynb', 
'input_params': {'param1': 'value1'}},
+output_config={'output_uri': 'folder/output/location/prefix', 
'output_format': 'ipynb'},
+execution_name='notebook_execution',
+poll_interval=10,
+)
+:param execution_name: The name of the notebook job to be executed, this 
is same as task_id.
+:param input_config: Configuration for the input file.
+Example: {'input_path': 'folder/input/notebook.ipynb', 'input_params': 
{'param1': 'value1'}}
+:param output_co

Re: [PR] Add AWS SageMaker Unified Studio Notebook Operator [airflow]

2025-01-16 Thread via GitHub


boring-cyborg[bot] commented on PR #45726:
URL: https://github.com/apache/airflow/pull/45726#issuecomment-2596912242

   Congratulations on your first Pull Request and welcome to the Apache Airflow 
community! If you have any issues or are unsure about any anything please check 
our Contributors' Guide 
(https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type 
annotations). Our [pre-commits]( 
https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-pre-commit-hooks)
 will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in 
`docs/` directory). Adding a new operator? Check this short 
[guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst)
 Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze 
environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst)
 for testing locally, it's a heavy docker but it ships with a working Airflow 
and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get 
the final approval from Committers.
   - Please follow [ASF Code of 
Conduct](https://www.apache.org/foundation/policies/conduct) for all 
communication including (but not limited to) comments on Pull Requests, Mailing 
list and Slack.
   - Be sure to read the [Airflow Coding style]( 
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail 
due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it 
better 🚀.
   In case of doubts contact the developers at:
   Mailing List: [email protected]
   Slack: https://s.apache.org/airflow-slack
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]