Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test all links and code examples in docs for GA/Beta. #3172

Closed
24 tasks done
daspecster opened this issue Mar 20, 2017 · 22 comments
Closed
24 tasks done

Test all links and code examples in docs for GA/Beta. #3172

daspecster opened this issue Mar 20, 2017 · 22 comments
Assignees
Labels
priority: p0 Highest priority. Critical issue. P0 implies highest priority. release blocking Required feature/issue must be fixed prior to next release.

Comments

@daspecster
Copy link
Contributor

daspecster commented Mar 20, 2017

Test all doc links and examples for...

/cc @lukesneeringer @omaray

@daspecster daspecster self-assigned this Mar 20, 2017
@dhermes
Copy link
Contributor

dhermes commented Mar 20, 2017

This is in some sense the grandchild of #212. I vote for the approach used in #2738.

@lukesneeringer lukesneeringer added priority: p0 Highest priority. Critical issue. P0 implies highest priority. release blocking Required feature/issue must be fixed prior to next release. labels Mar 20, 2017
@daspecster
Copy link
Contributor Author

daspecster commented Mar 24, 2017

Moving discussion from #3206 (comment) to this thread.

@lukesneeringer so here's the current status of snippets for GA.

  • Datastore snippet tests work/pass and are the most current architecture.
  • BigQuery snippet tests work/pass but they are the old architecture and need to be updated.
  • Storage snippet tests do not work and are the old architecture.
  • Logging snippet tests do not pass and are the old architecture.

The Right Thing™ to do is probably update the BigQuery and Storage snippets to the same methodology that Datastore is using. I think that can be done in reasonable time.
Logging however, is pretty huge and may take a fair bit of work.

I thought this was already a known, and that's why manual testing was the preferred route for now.

@dhermes
Copy link
Contributor

dhermes commented Mar 24, 2017

that's why manual testing was the preferred route for now.

There is an inflection point where doing things "by hand" starts to become longer than doing it the right way

@daspecster
Copy link
Contributor Author

@dhermes logging_snippets.py looks fairly outdated.

╰─$ python docs/logging_snippets.py
instantiate_client       : Instantiate client.
  ERROR: ValueError('This library only supports credentials from google-auth-library-python. See https://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html for help on authentication with this library.',)
client_list_entries      : List entries via client.
  ERROR: TypeError('Can not find message descriptor by type_url: type.googleapis.com/google.cloud.audit.AuditLog.',)
logger_usage             : Logger usage.
metric_crud              : Metric CRUD.
sink_storage             : Sink log entries to storage.
sink_bigquery            : Sink log entries to bigquery.
sink_pubsub              : Sink log entries to pubsub.
logging_handler          : None
  ERROR: TypeError('logging_handler() takes exactly 1 argument (2 given)',)
setup_logging            : None
  ERROR: TypeError('setup_logging() takes exactly 1 argument (2 given)',)

@dhermes
Copy link
Contributor

dhermes commented Mar 24, 2017

I am unaware of how up to date it is, just posted as a response to "Logging snippet tests do not exists."

@daspecster
Copy link
Contributor Author

@dhermes yeah thanks! I updated the status in the list.

@daspecster
Copy link
Contributor Author

@dhermes the Storage snippet for generate_upload_policy seems to be broken. I looked at the docs but I don't see where the breakdown is.

Here's the output when trying to upload with the generated HTML form.

<Error>
<Code>InvalidArgument</Code>
<Message>Invalid argument.</Message>
<Details>Cannot create buckets using a POST.</Details>
</Error>

Any ideas?

@dhermes
Copy link
Contributor

dhermes commented Mar 27, 2017

@jonparrott Wrote the snippet.

@theacodes
Copy link
Contributor

It's probably fine, it's just that the bucket has to exist.

@daspecster
Copy link
Contributor Author

@jonparrott in my test, I was/am using a bucket that exists.

@theacodes
Copy link
Contributor

Weird. That error message indicates otherwise!

@daspecster
Copy link
Contributor Author

@jonparrott haha I know! 😕

@theacodes
Copy link
Contributor

Can you try manually verifying it?

@daspecster
Copy link
Contributor Author

@jonparrott yeah that's how I'm getting the error. I'm not just running the snippets. The storage snippets need some updating to work.

bucket = client.bucket('my-bucket24356uytrew')
conditions = [
    ['starts-with', '$key', ''],
    {'acl': 'public-read'}]

policy = bucket.generate_upload_policy(conditions)

# Generate an upload form using the form fields.
policy_fields = ''.join(
    '<input type="hidden" name="{key}" value="{value}">'.format(
        key=key, value=value)
    for key, value in policy.items()
)

upload_form = (
    '<form action="http://{bucket_name}.storage.googleapis.com"'
    '   method="post" enctype="multipart/form-data">'
    '<input type="text" name="key" value="">'
    '<input type="hidden" name="bucket" value="{bucket_name}">'
    '<input type="hidden" name="acl" value="public-read">'
    '<input name="file" type="file">'
    '<input type="submit" value="Upload">'
    '{policy_fields}'
    '<form>').format(bucket_name=bucket.name, policy_fields=policy_fields)

print(upload_form)

@theacodes
Copy link
Contributor

Hmm. I'm at a a bit of a loss.

@daspecster
Copy link
Contributor Author

I was able to get the logging snippets running somewhat.

instantiate_client       : Instantiate client.
  ERROR: ValueError('This library only supports credentials from google-auth-library-python. See https://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html for help on authentication with this library.',)
client_list_entries      : List entries via client.
  ERROR: TypeError('Can not find message descriptor by type_url: type.googleapis.com/google.cloud.audit.AuditLog.',)
logger_usage             : Logger usage.
metric_crud              : Metric CRUD.
sink_storage             : Sink log entries to storage.
sink_bigquery            : Sink log entries to bigquery.
sink_pubsub              : Sink log entries to pubsub.
logging_handler          : None
setup_logging            : None

@theacodes
Copy link
Contributor

@daspecster can you file a separate bug about the storage policy document stuff and assign it to me? Thanks!

@daspecster
Copy link
Contributor Author

@jonparrott sure thing!

#3222

@daspecster
Copy link
Contributor Author

daspecster commented Mar 28, 2017

@daspecster
Copy link
Contributor Author

Ok all the PRs are merged.

I'm not saying the docs are perfect but they should be a lot closer.

I'm going to close this issue since all the outlined tasks are completed.

@lukesneeringer
Copy link
Contributor

🎉, thanks.

parthea pushed a commit that referenced this issue Oct 21, 2023
…dPlatform/python-docs-samples#3172)

* Update dependency grafeas to v0.4.0

* follow the field name changes

Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
Co-authored-by: Takashi Matsuo <tmatsuo@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p0 Highest priority. Critical issue. P0 implies highest priority. release blocking Required feature/issue must be fixed prior to next release.
Projects
None yet
Development

No branches or pull requests

4 participants