dagster-io / dagster

An orchestration platform for the development, production, and observation of data assets.
https://dagster.io
Apache License 2.0
11.95k stars 1.5k forks source link

Update GCSResource usage example #17576

Open pestrov opened 1 year ago

pestrov commented 1 year ago

What's the issue or suggestion?

The example of usage of GCSResource does not seem to work, as the GCP Storage Client is not intened to be used as a context manager.

https://docs.dagster.io/_apidocs/libraries/dagster-gcp#gcs-resource

Additional information

Dagster version: 1.5.5

It appears that the object returned by gcs.get_client() does not implement the enter method, which means it's not designed to be used as a context manager with the with statement.

When making an documented example, you recive an error:

@asset
def my_asset(gcs: GCSResource):
    with gcs.get_client() as client:
        # client is a google.cloud.storage.Client
        pass
dagster._core.errors.DagsterExecutionStepExecutionError: Error occurred while executing op "my_asset"::

AttributeError: __enter__

Changing the code to client = gcs.get_client() makes it a usable resouce.

One should either change the documentaton or implement the context manager (but it seeems like the client is not designed by Google to be used as a context manager, as the documentation lack such examples).

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.

yuhan commented 1 year ago

Thanks for writing up the issue. Will get that fixed soon. This seems like an oversight from the resource docs migration. cc @benpankow

LesterZ819 commented 12 months ago

Follow on this issue, I encountered the exact same error

hec10r commented 9 months ago

Same happened to me!