Giter VIP home page Giter VIP logo

docs-sdk-python's Introduction

Couchbase Python SDK Documentation

This repository hosts the documentation source for the Couchbase Python SDK.

Contributing

Check out the contributing guide to learn how to:

  • submit a bug or feedback issue

  • set up your documentation workspace

  • build the documentation

  • submit a pull request

Thank you for helping to make the documentation better.

Docs Component Configuration

This repository contains an Antora docs component. Keep in mind these key repository features:

  • Each branch’s antora.yml file configures the component name, version, and start page.

  • The ROOT module’s nav.adoc file stores the navigation for all of the modules.

  • Production branches use the release/X.Y naming pattern (for example, release/5.5, release/6.0).

    • The docs site playbook instructs Antora to automatically aggregate any branch names that start with release/.

Documentation Site Toolchain

The documentation source files written with AsciiDoc markup. Once merged into a version branch Antora aggregates the source files and their assets, converts to HTML, and publishes them to the staging and production sites. The docs site playbook orchestrates the docs components and site UI. See the contributing guide to learn more.

Automated Testing

This repository performs a check on the sample code upon opening a Pull Request. These tests need to succeed to perform the merge.

Test Framework Structure

TestInfra

The following steps conduct the check:

  1. The user opens a PR, triggering the GitHub Action

  2. The action creates a GitHub runner VM, and copies the repository over

  3. The runner starts the Docker test framework with docker compose --profile prod up --abort-on-container-exit. The flag is to verify the database container is also killed when the tests finish.

  4. The database and SDK containers start. The following two steps occur concurrently.

    • Database Container: Uses the server/sandbox image from Docker Hub. This image configures and starts Couchbase, setting up a one node cluster with the travel-sample bucket installed.

    • SDK Container: Builds the SDK image from a debian python base image, copying the repository over, and installing dependencies. It then uses wait-for-couchbase to ping the Couchbase container, until it confirms the database is fully configured and running.

  5. Once the SDK confirms the database is ready for tests, it runs the bats test file. Bats retries each test up to three times upon failure.

  6. When the tests have completed, both the SDK and Couchbase containers should die. If they persist, such as in a case where the test framework crashes, the GitHub Action instead destroys them.

Testing Code Samples Locally

You may want to run tests locally if you are adding/updating a code sample. The only prerequisites are a local copy of this repository, and Docker. You can start the local test environment by running the following command:

docker compose --profile local up

This creates two Docker containers with the same structure as described in Test Framework Structure, with the following changes:

  • The bats tests aren’t automatically performed once Couchbase has finished configuring

  • The repository files in the container mount onto the SDK repository in your local machine. This means any changes you make to the files on your local machine are instantly reflected in the container.

To run tests, you either need to use the Integrated Terminal feature on Docker Desktop, or SSH into the container from the command line. You can use the following command to use the SDK container shell:

docker exec -it python-sdk-local /bin/bash

Once within the container, run the following command to run a single test:

bats -f "<test_name>" test.bats

The -f flag only runs tests that match the given regular expression. As test names are in a standard format, you can also run the following to test all the files in a given module:

bats -f "<module name>" test.bats

Creating a New Test

To add a new test, append the following to the test.bats file.

@test "[<module>] - <code_file>" {
  runExample $<module_dir_var> <code_file>
  assert_success
}

You can find the module directory variables in test_helper.bash. The test name is "[<module>] - <code_file>". The name can be anything, but this standard format allows you to carry out single tests, as described in the preceding section. For more information about creating tests, see the bats documentation.

docs-sdk-python's People

Contributors

amarantha-k avatar aschneidz avatar cb-docs-robot avatar charlie-hayes avatar chvck avatar danzibob avatar davidkelly avatar demetrischr avatar griels avatar ingenthr avatar jamesnocentini avatar maria-robobug avatar osfameron avatar richardsmedley avatar simon-dew avatar steveyen avatar thejcfactor avatar tom-rosewell avatar xpressiv avatar

Stargazers

 avatar  avatar

Watchers

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

docs-sdk-python's Issues

Correction in document

In the below line Java SDK is to be replaced with Python SDK as the document is for python and link is taking us to full text search doc of python SDK.

'A detailed example of performing Full Text Search queries from the Java SDK is provided in Searching from the SDK.'

result dont have content_as

tag::get-func[]

get document function

def get_airline_by_key(key):
print("\nGet Result: ")
try:
result = cb_coll.get(key)
print(result.content_as[str])
except Exception as e:
print(e)

end::get-func[]

result don't have a content_as

print(result)
get_airline_by_key("airline_8091")
Get Result:
ValueResult<rc=0x0, key='airline_8091', value={'type': 'airline', 'id': 8091, 'callsign': 'CBS', 'iata': None, 'icao': None, 'name': 'Couchbase Airways'}, cas=0x1648131ffc710000, flags=0x2000000, tracing_context=0, tracing_output={'s': 'kv:Unknown', 'c': 'b32c447763e2e10d/083941b5d68313f8', 'i': 122044414642305708, 'b': 'travel-sample', 'l': '192.168.1.126:46956', 'r': '192.168.1.123:11210', 't': 2500000}>

Sample Code for Asyncio doesn't work with the latest Couchbase library

To be specific, the latest Couchbase library (4.0.4) breaks:
txcouchbase_operations.py

And the first two lines:
from twisted.internet import reactor
from txcouchbase.cluster import TxCluster

throws an error:
ReactorAlreadyInstalledError: reactor already installed

I'm using twisted 22.8.0 and Python 3.8.13. After downgrading couchbase python lib to 3.1.2, everything works.

This bug basically makes the txcouchbase lib useless. Please fix it asap. Thanks.

Is Error Handling example upto date?

is_retryable does not seem to be available for usage. I can see is_transient. Should we use that or am I missing something?
Even the exception caught is coucbase.exceptions.CouchbaseError, hasn't this changed to coucbase.exceptions.CouchbaseException?

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.