Skip to content

Commit 0468a4d

Browse files
authored
Revert "docs: add code snippet for storing dataframes to a CSV file (#1943)" (#1952)
This reverts commit a511e09.
1 parent b19ea98 commit 0468a4d

File tree

3 files changed

+10
-31
lines changed

3 files changed

+10
-31
lines changed

samples/snippets/conftest.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Generator, Iterator
15+
from typing import Iterator
1616

17-
from google.cloud import bigquery, storage
17+
from google.cloud import bigquery
1818
import pytest
1919
import test_utils.prefixer
2020

@@ -42,27 +42,11 @@ def bigquery_client() -> bigquery.Client:
4242
return bigquery_client
4343

4444

45-
@pytest.fixture(scope="session")
46-
def storage_client(project_id: str) -> storage.Client:
47-
return storage.Client(project=project_id)
48-
49-
5045
@pytest.fixture(scope="session")
5146
def project_id(bigquery_client: bigquery.Client) -> str:
5247
return bigquery_client.project
5348

5449

55-
@pytest.fixture(scope="session")
56-
def gcs_bucket(storage_client: storage.Client) -> Generator[str, None, None]:
57-
bucket_name = "bigframes_blob_test"
58-
59-
yield bucket_name
60-
61-
bucket = storage_client.get_bucket(bucket_name)
62-
for blob in bucket.list_blobs():
63-
blob.delete()
64-
65-
6650
@pytest.fixture(autouse=True)
6751
def reset_session() -> None:
6852
"""An autouse fixture ensuring each sample runs in a fresh session.
@@ -94,6 +78,11 @@ def dataset_id_eu(bigquery_client: bigquery.Client, project_id: str) -> Iterator
9478
bigquery_client.delete_dataset(dataset, delete_contents=True, not_found_ok=True)
9579

9680

81+
@pytest.fixture(scope="session")
82+
def gcs_dst_bucket() -> str:
83+
return "gs://bigframes_blob_test"
84+
85+
9786
@pytest.fixture
9887
def random_model_id(
9988
bigquery_client: bigquery.Client, project_id: str, dataset_id: str

samples/snippets/multimodal_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# limitations under the License.
1414

1515

16-
def test_multimodal_dataframe(gcs_bucket: str) -> None:
16+
def test_multimodal_dataframe(gcs_dst_bucket: str) -> None:
1717
# destination folder must be in a GCS bucket that the BQ connection service account (default or user provided) has write access to.
18-
dst_bucket = f"gs://{gcs_bucket}"
18+
dst_bucket = gcs_dst_bucket
1919
# [START bigquery_dataframes_multimodal_dataframe_create]
2020
import bigframes
2121

samples/snippets/sessions_and_io_test.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
# limitations under the License.
1414

1515

16-
def test_sessions_and_io(project_id: str, dataset_id: str, gcs_bucket: str) -> None:
16+
def test_sessions_and_io(project_id: str, dataset_id: str) -> None:
1717
YOUR_PROJECT_ID = project_id
1818
YOUR_DATASET_ID = dataset_id
1919
YOUR_LOCATION = "us"
20-
YOUR_BUCKET = gcs_bucket
2120

2221
# [START bigquery_dataframes_create_and_use_session_instance]
2322
import bigframes
@@ -140,15 +139,6 @@ def test_sessions_and_io(project_id: str, dataset_id: str, gcs_bucket: str) -> N
140139
# [END bigquery_dataframes_read_data_from_csv]
141140
assert df is not None
142141

143-
# [START bigquery_dataframes_write_data_to_csv]
144-
import bigframes.pandas as bpd
145-
146-
df = bpd.DataFrame({"my_col": [1, 2, 3]})
147-
# Write a dataframe to a CSV file in GCS
148-
df.to_csv(f"gs://{YOUR_BUCKET}/myfile*.csv")
149-
# [END bigquery_dataframes_write_data_to_csv]
150-
assert df is not None
151-
152142
# [START bigquery_dataframes_read_data_from_bigquery_table]
153143
import bigframes.pandas as bpd
154144

0 commit comments

Comments
 (0)