Skip to content

Initial commit #1

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

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

44 changes: 6 additions & 38 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,13 @@
## Purpose
<!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? -->
* ...

## Does this introduce a breaking change?
<!-- Mark one with an "x". -->
```
[ ] Yes
[ ] No
```

## Pull Request Type
What kind of change does this Pull Request introduce?
<!-- Verify that you have linted and formatted your Python code correctly -->

<!-- Please check the one that applies to this PR using "x". -->
```bash
pip install flake8 black
```
[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:
```

## How to Test
* Get the code

```
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
```
```bash
flake8 --verbose *.py

* Test the code
<!-- Add steps to run the tests suite and/or manually test -->
```
black --verbose --line-length 79 *.py
```

## What to Check
Verify that the following are valid
* ...

## Other Information
<!-- Add any other helpful information that may be needed here. -->
56 changes: 56 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Validate Python projects
on:
workflow_dispatch:
pull_request:
jobs:
index:
name: Generate matrix of project directories
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.set_output.outputs.matches }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: List directories
run: find -name '*.py' -type 'f' -printf '%h\n' | uniq
- name: Set output
id: set_output
run: echo "matches=$(find -name '*.py' -type 'f' -printf '%h\n' | uniq | jq --null-input --raw-input --compact-output --sort-keys '[inputs|select(length > 0)]')" >> $GITHUB_OUTPUT
validate:
name: Validate Python project
needs: index
runs-on: ubuntu-latest
container: python:3.7
strategy:
matrix:
project-directory: ${{ fromJson(needs.index.outputs.projects) }}
defaults:
run:
working-directory: ${{ matrix.project-directory }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Output Python version
run: python --version
- name: Install packages
run: pip install black flake8
- name: Lint with flake8
run: flake8 --count --verbose *.py
- name: Check format with black
run: black --check --verbose --line-length 79 *.py
summarize:
name: All code validated
needs:
- index
- validate
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Evaluate status of jobs
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}
run: exit 1
32 changes: 32 additions & 0 deletions 601-emulator/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# <imports>
from gremlin_python.driver import client

# </imports>

# <client>
client = client.Client(
url="ws://localhost:8901/",
traversal_source="g",
username="/dbs/db1/colls/coll1",
password=(
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnq"
"yMsEcaGQy67XIw/Jw=="
),
)
# </client>

# <graph>
client.submit(message="g.V().drop()")
# </graph>

# <insert>
client.submit(
message=(
"g.addV('product').property('id', prop_id).property('name', prop_name)"
),
bindings={
"prop_id": "68719518371",
"prop_name": "Kiama classic surfboard",
},
)
# </insert>
1 change: 1 addition & 0 deletions 601-emulator/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gremlinpython==3.*
13 changes: 0 additions & 13 deletions CHANGELOG.md

This file was deleted.

76 changes: 0 additions & 76 deletions CONTRIBUTING.md

This file was deleted.

57 changes: 0 additions & 57 deletions README.md

This file was deleted.

41 changes: 41 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Azure Cosmos DB for NoSQL client library samples for Apache Gremlin

[![Validate Python projects](https://github.com/Azure-Samples/cosmos-db-apache-gremlin-python-samples/actions/workflows/validate.yml/badge.svg)](https://github.com/Azure-Samples/cosmos-db-apache-gremlin-python-samples/actions/workflows/validate.yml)

## Getting started

This repo has a [devcontainer](https://containers.dev) environment making it easy to get started.

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/cosmos-db-apache-gremlin-python-samples?quickstart=1)

### Run the app

Configure your Azure Cosmos DB credentials as environment variables.

```bash
export COSMOS_ENDPOINT="<cosmos-account-URI>"
export COSMOS_KEY="<cosmos-account-PRIMARY-KEY>"
```

> **💡 TIP**: If you don't have an Azure Cosmos DB account, [create a free account](https://cosmos.azure.com/try/).

Run the quickstart sample app using the [`gremlinpython`](https://pypi.org/project/gremlinpython/) package from PyPI.

```bash
pip install gremlinpython
python 001-quickstart/app.py
```

### Validate any changes you make

If you change the code, run the linter and code formatter.

```bash
pip install flake8
flake8 --verbose 001-quickstart/app.py
```

```bash
pip install black
black --verbose 001-quickstart/app.py
```