Reading a file from Yandex Object Storage
Written by
Updated at October 23, 2025
Use a directed acyclic graph to read files from Yandex Object Storage of the service account attached to your Apache Airflow™ cluster.
Prepare the DAG file and run the graph
-
Create a local file named
read_file_from_dags_bucket.pyand paste the following script to it:from airflow.settings import DAGS_FOLDER from airflow.decorators import dag, task @dag(schedule=None) def read_file_from_dags_bucket(): @task def read_file(): with open(f'{DAGS_FOLDER}/data/airflow.txt') as file: content = file.read() print(f"file content: {content}") read_file() read_file_from_dags_bucket() -
Upload the
read_file_from_dags_bucket.pyDAG file to the bucket you created earlier. This will automatically create a graph with the same name in the Apache Airflow™ web interface. -
Make sure a new graph named
read_file_from_dags_buckethas appeared in the DAGs section.It may take a few minutes to load a DAG file from the bucket.
-
To run the graph, click
in the line with its name.
Check the result
To check the result in the Apache Airflow™ web interface:
Apache Airflow™ version below 3.0
Apache Airflow™ version 3.0 or higher
- In the DAGs section, click the
read_file_from_dags_bucketgraph. - Go to the Graph section.
- Select read_file.
- Go to Logs.
- Make sure the logs contain the
file content: {content}line, wherecontentis the file contents. This means the query was successful.
- In the DAGs section, click the
read_file_from_dags_bucketgraph. - Go to Tasks.
- Select read_file.
- Go to Tasks Instances.
- Select the task instance.
- The Logs section will open.
- Make sure the logs contain the
file content: {content}line, wherecontentis the file contents. This means the query was successful.