-
Notifications
You must be signed in to change notification settings - Fork 10
Notebooks examples #238
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
+1,110
−0
Merged
Notebooks examples #238
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
dddf16d
Added proposal for sync
MarcelGeo 9dbc582
added push an dpull using client.
MarcelGeo cb8807a
add user management example
fernandinand 103e36c
Fix users creation from CSV section
fernandinand f892757
Add scenario for projects management
fernandinand 9a4b8bf
Fix project version/status entry.
fernandinand 3781d4c
some tnning and cleanup for 1. and 3. scenario
MarcelGeo cf73378
small tweaks
MarcelGeo a1c12e6
make images smaller
MarcelGeo b39e6bb
AB tteams tweaks
MarcelGeo 90d582d
Add README with some basic info
fernandinand 07218d5
Merge remote-tracking branch 'origin/master' into notebooks-examples
MarcelGeo df732ce
Update examples/02_sync.ipynb
MarcelGeo 8ab9a87
Update examples/02_sync.ipynb
MarcelGeo 180cc6a
Update examples/03_projects.ipynb
MarcelGeo efde843
Update examples/03_projects.ipynb
MarcelGeo 7fd7581
Update examples/README.md
MarcelGeo c8258f3
Update examples/03_projects.ipynb
MarcelGeo 7133736
Update examples/03_projects.ipynb
MarcelGeo 7f8396c
Update examples/03_projects.ipynb
MarcelGeo 5c0f5a9
Update examples/03_projects.ipynb
MarcelGeo 3929c1b
Update examples/03_projects.ipynb
MarcelGeo c0378f4
Update examples/02_sync.ipynb
MarcelGeo ccedfe6
Update examples/02_sync.ipynb
MarcelGeo 7056aed
Update examples/02_sync.ipynb
MarcelGeo 0b3e6ce
Update examples/02_sync.ipynb
MarcelGeo 9499c1f
Update examples/02_sync.ipynb
MarcelGeo 96ee0a6
Update examples/02_sync.ipynb
MarcelGeo c566a27
Update examples/02_sync.ipynb
MarcelGeo 55b743a
Update examples/02_sync.ipynb
MarcelGeo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| { | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "name": "python", | ||
| "display_name": "Python (Pyodide)", | ||
| "language": "python" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "python", | ||
| "version": 3 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.8" | ||
| }, | ||
| "colab": { | ||
| "provenance": [], | ||
| "collapsed_sections": [ | ||
| "x8IVfy9K5Z4l", | ||
| "7VMIPQo2yTmQ" | ||
| ], | ||
| "authorship_tag": "ABX9TyPXXcFNdfLOsA7CkWfkKXfJ" | ||
| } | ||
| }, | ||
| "nbformat_minor": 4, | ||
| "nbformat": 4, | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "# Mergin Maps Users Management", | ||
| "metadata": { | ||
| "id": "ngTJ3YbHlb8s" | ||
| } | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "Mergin Maps API allows you to fully manage your workspace users, it's roles and project permissions.", | ||
| "metadata": { | ||
| "id": "q0eLjSMzlwdx" | ||
| } | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "First let's install mergin maps client", | ||
| "metadata": { | ||
| "id": "IKmFEjG-mmL6" | ||
| } | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": "!pip install mergin-client", | ||
| "metadata": { | ||
| "id": "I_vpP6NnmqV7" | ||
| }, | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "Login to Mergin Maps using your workspace user with `Owner` permission.", | ||
| "metadata": { | ||
| "id": "u05lxbRQm2VF" | ||
| } | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": "# Use here your login username and password\nLOGIN=\"\"\nPASSW=\"\"\n\nimport mergin\n\nclient = mergin.MerginClient(login=LOGIN, password=PASSW)", | ||
| "metadata": { | ||
| "colab": { | ||
| "base_uri": "https://localhost:8080/" | ||
| }, | ||
| "id": "dWQorVqZnRNl", | ||
| "executionInfo": { | ||
| "status": "ok", | ||
| "timestamp": 1748364457967, | ||
| "user_tz": -60, | ||
| "elapsed": 1822, | ||
| "user": { | ||
| "displayName": "Fernando Ribeiro", | ||
| "userId": "15488710231554262191" | ||
| } | ||
| }, | ||
| "outputId": "778487c5-b0b5-4a7f-a024-33122e49b6fb", | ||
| "trusted": true | ||
| }, | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "Let's create a dummy workspace and project as base for our users management example.\n\nChange the variable `WORKSPACE`with your desired workspace name and `PROJECT` with project name.", | ||
| "metadata": { | ||
| "id": "gFN3jXIjntwf" | ||
| } | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": "# Add here your existing workspace name and the new project name\nWORKSPACE=\"\"\nPROJECT=\"\"\n\n# Create new workspace\n#INFO: Only uncomment if you are able to create a new workspace. Mergin Maps free tier only allows for 1 workspace per user. In this case use your existing workspace.\n#client.create_workspace(WORKSPACE) \n\n# Create new dummy project (public accessible)\nclient.create_project(project_name=PROJECT, namespace=WORKSPACE, is_public=True)", | ||
| "metadata": { | ||
| "id": "27rA4VfgoJjy", | ||
| "executionInfo": { | ||
| "status": "ok", | ||
| "timestamp": 1748364795430, | ||
| "user_tz": -60, | ||
| "elapsed": 745, | ||
| "user": { | ||
| "displayName": "Fernando Ribeiro", | ||
| "userId": "15488710231554262191" | ||
| } | ||
| } | ||
| }, | ||
| "outputs": [], | ||
| "execution_count": 3 | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "Create some users on your Mergin Maps example workspace from the provided example file in `01_users_assets/users.csv` with random permissions.", | ||
| "metadata": { | ||
| "id": "SXimIDIDqb9J" | ||
| } | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": "import csv\nimport string\nimport random\n\nfrom mergin.common import WorkspaceRole\n\npermissions = [WorkspaceRole.EDITOR,\n WorkspaceRole.READER,\n WorkspaceRole.WRITER]\n\n\ntry:\n with open('01_users_assets/users.csv', mode='r', newline='', encoding='utf-8') as csvfile:\n reader = csv.reader(csvfile)\n header = next(reader) # Skip header\n first_data_row = next(reader) # Get first data row\n if len(first_data_row) >= 2: # Check if there are at least two columns\n username = first_data_row[0]\n email = first_data_row[1]\n # add new mergin maps user\n client.create_user(username=username, password=random.choices(string.ascii_uppercase + string.digits, k=12), email=email, workspace_id=WORKSPACE, workspace_role=random.choice(permissions))\n print(f\"User '{username}' created successfully.\")\n else:\n print(\"First data row does not have enough columns.\")\nexcept FileNotFoundError:\n print(f\"File '{filename}' not found for processing example.\")\nexcept StopIteration:\n print(f\"File '{filename}' does not contain enough data rows for processing example.\")\nexcept Exception as e:\n print(f\"An error occurred during processing example: {e}\")\n", | ||
| "metadata": { | ||
| "id": "Lp351dFYquVs" | ||
| }, | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "Let's change permission level for a specific user to `READER`.", | ||
| "metadata": { | ||
| "id": "OoCFI9u7uClQ" | ||
| } | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": "client.update_workspace_member(username='agreen', workspace_id=WORKSPACE, workspace_role=WorkspaceRole.READER)", | ||
| "metadata": { | ||
| "id": "6QG8Smj2uI2l" | ||
| }, | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "Remove the same user from our dummy example project", | ||
| "metadata": { | ||
| "id": "PpSxZfRfujj7" | ||
| } | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": "client.remove_project_collaborator(project_path='{workspace}/{project}'.format(workspace=WORKSPACE, project=PROJECT), username='agreen')", | ||
| "metadata": { | ||
| "id": "5_7lhNhVuukI" | ||
| }, | ||
| "outputs": [], | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": "Remove a user from an workspace", | ||
| "metadata": {} | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": "client.remove_workspace_member(username='agreen', workspace_id=WORKSPACE)", | ||
| "metadata": { | ||
| "trusted": true | ||
| }, | ||
| "outputs": [], | ||
| "execution_count": null | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| username,email | ||
MarcelGeo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| agreen,agreen@example.com | ||
| bsmith,bsmith@example.com | ||
| cjones,cjones@example.com | ||
| dwilliams,dwilliams@example.com | ||
| ebrown,ebrown@example.com | ||
| fdavis,fdavis@example.com | ||
| gmiller,gmiller@example.com | ||
| hwilson,hwilson@example.com | ||
| imoore,imoore@example.com | ||
| jtaylor,jtaylor@example.com | ||
| kanderson,kanderson@example.com | ||
| lthomas,lthomas@example.com | ||
| mjackson,mjackson@example.com | ||
| nwhite,nwhite@example.com | ||
| oharris,oharris@example.com | ||
| pmartin,pmartin@example.com | ||
| qthompson,qthompson@example.com | ||
| rgarcia,rgarcia@example.com | ||
| smartinez,smartinez@example.com | ||
| trobinson,trobinson@example.com | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.