Code Monkey home page Code Monkey logo

python-docs-samples's Introduction

Google Cloud Platform Python Samples

Python samples for Google Cloud Platform products.

Build Status Build Status Build Status Build Status Build Status

Google Cloud Samples

Check out some of the samples found on this repository on the Google Cloud Samples page.

Setup

  1. Install pip and virtualenv if you do not already have them.

  2. Clone this repository:

    git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
    
  3. Obtain authentication credentials.

    Create local credentials by running the following command and following the oauth2 flow (read more about the command here):

    gcloud auth application-default login
    

    Read more about Google Cloud Platform Authentication.

How to run a sample

  1. Change directory to one of the sample folders, e.g. logging/cloud-client:

    cd logging/cloud-client/
    
  2. Create a virtualenv. Samples are compatible with Python 3.6+.

    python3 -m venv env
    source env/bin/activate
    
  3. Install the dependencies needed to run the samples.

    pip install -r requirements.txt
    
  4. Run the sample:

    python snippets.py
    

Contributing

Contributions welcome! See the Contributing Guide.

python-docs-samples's People

Contributors

alixhami avatar andrewsg avatar anguillanneuf avatar avani-thakker-crest avatar averikitsch avatar busunkim96 avatar dandhlee avatar davidcavazos avatar dependabot[bot] avatar dizcology avatar dpebot avatar engelke avatar gcf-owl-bot[bot] avatar gguuss avatar holtskinner avatar jerjou avatar kurtisvg avatar kweinmeister avatar leahecole avatar m-strzelczyk avatar msampathkumar avatar munkhuushmgl avatar nnegrey avatar noerog avatar parthea avatar renovate-bot avatar telpirion avatar tswast avatar waprin avatar yoshi-automation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-docs-samples's Issues

"Empty or missing scope not allowed" in load_data_by_post

Hello

I had an exception "Empty or missing scope not allowed" when running the sample load_data_by_post.

I fixed it by creating the scope after getting credentials :

credentials = GoogleCredentials.get_application_default()
scope = ['https://www.googleapis.com/auth/bigquery']
credentials = credentials.create_scoped(scope)

Regards

Storage transfer samples need full integration tests

The current tests for the storage transfer service mock everything, which isn't very useful in terms of ensuring the sample still works with the live API.

We need to come up with a plan to test these. The only one that might be difficult is the AWS one, as it will require us to have an AWS account.

All console-runnable samples should use better main pattern.

Instead of:

def main(argv):
    args = parser.parse_args(argv[1:])

if __name__ == '__main__':
    main(sys.argv)

It should be

def descriptive_function_name(arg1, arg2, arg3):
    ...

if __name__ == '__main__':
    args = parser.parse_args()
    descriptive_function_name(args.arg1, args.arg2, args.arg3)

Figure out a way to test the django samples

The django apps don't like being imported as part of a larger package, apparently. We need to either find a way for the apps to play nice with nose or figure out a way to get nose and coverage to cooperate if we remove all of the packages.

BiqQuery Streaming Insert example is different from official documentation

According to BigQuery (BQ) API documentation, streaming insert (insertAll) input should be formed as
{"rows": [ {"insertId": "A String",
"json": {"a_key": ""},
},
],
}

(see https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/python/latest/bigquery_v2.tabledata.html)

whereas in the example bigquery/api/streaming.py the input is formed differently as

insert_all_data = {
'insertId': str(uuid.uuid4()),
'rows': [{'json': row}]
}

The difference is where you place the 'insertId' key. A separate insertId should be with each row, not one 'insertId' at the same level with 'rows'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.