Skip to content

Commit a12a4a5

Browse files
authored
gcs to gcs deprecation removal (#39726)
1 parent f067727 commit a12a4a5

File tree

3 files changed

+7
-51
lines changed

3 files changed

+7
-51
lines changed

docs/apache-airflow-providers-google/operators/transfer/gcs_to_gcs.rst

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,28 +116,11 @@ Copy multiple files
116116

117117
There are several ways to copy multiple files, various examples of which are presented following.
118118

119-
.. exampleinclude:: /../../tests/system/providers/google/cloud/gcs/example_gcs_to_gcs.py
120-
:language: python
121-
:dedent: 4
122-
:start-after: [START howto_operator_gcs_to_gcs_wildcard]
123-
:end-before: [END howto_operator_gcs_to_gcs_wildcard]
124-
125-
The ``source_object`` value may contain one wild card, denoted as "*". All files matching the wild card expression will
126-
be copied. In this example, all root level files ending with ``.txt`` in ``BUCKET_1_SRC`` will be copied to the ``data``
127-
folder in ``BUCKET_1_DST``, with file names unchanged.
128-
129-
.. exampleinclude:: /../../tests/system/providers/google/cloud/gcs/example_gcs_to_gcs.py
130-
:language: python
131-
:dedent: 4
132-
:start-after: [START howto_operator_gcs_to_gcs_delimiter]
133-
:end-before: [END howto_operator_gcs_to_gcs_delimiter]
134-
135-
For source_objects with no wildcard, all files in source_objects would be listed, using provided delimiter if any.
136-
Then copy files from source_objects to destination_object and rename each source file.
137-
138119
As previously stated, the ``delimiter`` field, as well as utilizing a wildcard (``*``) in the source object(s),
139120
are both deprecated. Thus, it is not recommended to use them - but to utilize ``match_glob`` instead, as follows:
140121

122+
The following example would copy the files that matches the glob pattern in ``data/`` folder from ``BUCKET_1_SRC`` GCS bucket to the ``backup/`` folder in ``BUCKET_1_DST`` bucket.
123+
141124
.. exampleinclude:: /../../tests/system/providers/google/cloud/gcs/example_gcs_to_gcs.py
142125
:language: python
143126
:dedent: 4
@@ -153,9 +136,7 @@ the ``BUCKET_1_SRC`` GCS bucket to the ``backup/`` folder in ``BUCKET_1_DST`` bu
153136
:start-after: [START howto_operator_gcs_to_gcs_without_wildcard]
154137
:end-before: [END howto_operator_gcs_to_gcs_without_wildcard]
155138

156-
The delimiter field may be specified to select any source files starting with ``source_object`` and ending with the
157-
value supplied to ``delimiter``. This example uses the ``delimiter`` value to implement the same functionality as the
158-
prior example.
139+
159140

160141
.. exampleinclude:: /../../tests/system/providers/google/cloud/gcs/example_gcs_to_gcs.py
161142
:language: python
@@ -164,8 +145,7 @@ prior example.
164145
:end-before: [END howto_operator_gcs_to_gcs_list]
165146

166147
Lastly, files may be copied by omitting the ``source_object`` argument and instead supplying a list to ``source_objects``
167-
argument. In this example, ``OBJECT_1`` and ``OBJECT_2`` will be copied from ``BUCKET_1_SRC`` to ``BUCKET_1_DST``. Instead
168-
of specific file names, the list can contain one or more wild card expressions, each with no more than one wild card.
148+
argument. In this example, ``OBJECT_1`` and ``OBJECT_2`` will be copied from ``BUCKET_1_SRC`` to ``BUCKET_1_DST``.
169149
Supplying a list of size 1 functions the same as supplying a value to the ``source_object`` argument.
170150

171151
Move single file

tests/always/test_example_dags.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"tests/system/providers/google/cloud/bigquery/example_bigquery_operations.py",
5252
"tests/system/providers/google/cloud/dataproc/example_dataproc_gke.py",
5353
"tests/system/providers/google/cloud/gcs/example_gcs_sensor.py",
54-
"tests/system/providers/google/cloud/gcs/example_gcs_to_gcs.py",
5554
"tests/system/providers/google/cloud/kubernetes_engine/example_kubernetes_engine.py",
5655
"tests/system/providers/google/cloud/kubernetes_engine/example_kubernetes_engine_async.py",
5756
"tests/system/providers/google/cloud/kubernetes_engine/example_kubernetes_engine_job.py",

tests/system/providers/google/cloud/gcs/example_gcs_to_gcs.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -166,37 +166,16 @@ def create_workdir() -> str:
166166
)
167167
# [END howto_operator_gcs_to_gcs_single_file]
168168

169-
# [START howto_operator_gcs_to_gcs_wildcard]
170-
copy_files_with_wildcard = GCSToGCSOperator(
171-
task_id="copy_files_with_wildcard",
172-
source_bucket=BUCKET_NAME_SRC,
173-
source_object="data/*.txt",
174-
destination_bucket=BUCKET_NAME_DST,
175-
destination_object="backup/",
176-
)
177-
# [END howto_operator_gcs_to_gcs_wildcard]
178-
179169
# [START howto_operator_gcs_to_gcs_without_wildcard]
180-
copy_files_without_wildcard = GCSToGCSOperator(
181-
task_id="copy_files_without_wildcard",
170+
copy_files = GCSToGCSOperator(
171+
task_id="copy_files",
182172
source_bucket=BUCKET_NAME_SRC,
183173
source_object="subdir/",
184174
destination_bucket=BUCKET_NAME_DST,
185175
destination_object="backup/",
186176
)
187177
# [END howto_operator_gcs_to_gcs_without_wildcard]
188178

189-
# [START howto_operator_gcs_to_gcs_delimiter]
190-
copy_files_with_delimiter = GCSToGCSOperator(
191-
task_id="copy_files_with_delimiter",
192-
source_bucket=BUCKET_NAME_SRC,
193-
source_object="data/",
194-
destination_bucket=BUCKET_NAME_DST,
195-
destination_object="backup/",
196-
delimiter=".txt",
197-
)
198-
# [END howto_operator_gcs_to_gcs_delimiter]
199-
200179
# [START howto_operator_gcs_to_gcs_match_glob]
201180
copy_files_with_match_glob = GCSToGCSOperator(
202181
task_id="copy_files_with_match_glob",
@@ -264,9 +243,7 @@ def delete_work_dir(create_workdir_result: str) -> None:
264243
sync_to_subdirectory,
265244
sync_from_subdirectory,
266245
copy_single_file,
267-
copy_files_with_wildcard,
268-
copy_files_without_wildcard,
269-
copy_files_with_delimiter,
246+
copy_files,
270247
copy_files_with_match_glob,
271248
copy_files_with_list,
272249
move_single_file,

0 commit comments

Comments
 (0)