├── 4_Flask
└── Flask_App
│ ├── cosmosfunc
│ ├── __init__.py
│ └── cosmos.py
│ ├── .deployment
│ ├── static
│ ├── logo.JPG
│ ├── slide_arch.JPG
│ └── slide_arch.PNG
│ ├── css
│ └── homepage.css
│ ├── requirements.txt
│ ├── README.md
│ ├── templates
│ ├── issueSummary.htm
│ ├── issue.htm
│ ├── repo.htm
│ ├── keyphraseSummary.htm
│ ├── home.htm
│ ├── repoSummary.htm
│ └── base.html
│ ├── .vscode
│ ├── settings.json
│ └── launch.json
│ ├── .gitignore
│ └── app.py
├── 00_HelloWorld
├── requirements.txt
├── HttpTrigger1
│ ├── sample.dat
│ ├── function.json
│ └── __init__.py
├── .funcignore
├── proxies.json
├── .vscode
│ ├── extensions.json
│ ├── settings.json
│ ├── launch.json
│ └── tasks.json
├── host.json
└── .gitignore
├── 0_HelloWorld
├── requirements.txt
├── Build2020blank
│ ├── sample.dat
│ ├── function.json
│ └── __init__.py
├── .funcignore
├── proxies.json
├── .vscode
│ ├── extensions.json
│ ├── settings.json
│ ├── launch.json
│ └── tasks.json
├── host.json
└── .gitignore
├── 2_ReadUnzipStore
├── requirements.txt
├── .funcignore
├── DownloadUnzipStore_GHData
│ ├── sample.dat
│ ├── function.json
│ └── __init__.py
├── proxies.json
├── .vscode
│ ├── extensions.json
│ ├── launch.json
│ ├── settings.json
│ └── tasks.json
├── host.json
└── .gitignore
├── 1_CallAPI
├── DownloadStore
│ ├── sample.dat
│ ├── function.json
│ └── __init__.py
├── requirements.txt
├── .funcignore
├── proxies.json
├── .vscode
│ ├── extensions.json
│ ├── launch.json
│ ├── settings.json
│ └── tasks.json
├── host.json
└── .gitignore
├── 3_ML
├── .funcignore
├── proxies.json
├── .vscode
│ ├── extensions.json
│ ├── launch.json
│ ├── settings.json
│ └── tasks.json
├── requirements.txt
├── host.json
├── cogservicesscript
├── CosmosDB_Cog_Trigger
│ ├── function.json
│ └── __init__.py
└── .gitignore
├── .gitattributes
├── Slides
└── Build Python Applications In Azure Faster With Visual Studio Code_v2_gh.pptx
├── LICENSE
├── README.md
└── .gitignore
/4_Flask/Flask_App/cosmosfunc/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/00_HelloWorld/requirements.txt:
--------------------------------------------------------------------------------
1 | azure-functions
--------------------------------------------------------------------------------
/0_HelloWorld/requirements.txt:
--------------------------------------------------------------------------------
1 | azure-functions
--------------------------------------------------------------------------------
/2_ReadUnzipStore/requirements.txt:
--------------------------------------------------------------------------------
1 | azure-functions
2 | requests
--------------------------------------------------------------------------------
/00_HelloWorld/HttpTrigger1/sample.dat:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Azure"
3 | }
--------------------------------------------------------------------------------
/1_CallAPI/DownloadStore/sample.dat:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Azure"
3 | }
--------------------------------------------------------------------------------
/0_HelloWorld/Build2020blank/sample.dat:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Azure"
3 | }
--------------------------------------------------------------------------------
/1_CallAPI/requirements.txt:
--------------------------------------------------------------------------------
1 | azure-functions
2 | azure-storage-blob
3 | requests
--------------------------------------------------------------------------------
/3_ML/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | local.settings.json
4 | test
5 | .venv
--------------------------------------------------------------------------------
/4_Flask/Flask_App/.deployment:
--------------------------------------------------------------------------------
1 | [config]
2 | SCM_DO_BUILD_DURING_DEPLOYMENT=true
--------------------------------------------------------------------------------
/1_CallAPI/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | local.settings.json
4 | test
5 | .venv
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/00_HelloWorld/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | local.settings.json
4 | test
5 | .venv
--------------------------------------------------------------------------------
/0_HelloWorld/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | local.settings.json
4 | test
5 | .venv
--------------------------------------------------------------------------------
/2_ReadUnzipStore/.funcignore:
--------------------------------------------------------------------------------
1 | .git*
2 | .vscode
3 | local.settings.json
4 | test
5 | .venv
--------------------------------------------------------------------------------
/2_ReadUnzipStore/DownloadUnzipStore_GHData/sample.dat:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Azure"
3 | }
--------------------------------------------------------------------------------
/3_ML/proxies.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/proxies",
3 | "proxies": {}
4 | }
5 |
--------------------------------------------------------------------------------
/0_HelloWorld/proxies.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/proxies",
3 | "proxies": {}
4 | }
5 |
--------------------------------------------------------------------------------
/1_CallAPI/proxies.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/proxies",
3 | "proxies": {}
4 | }
5 |
--------------------------------------------------------------------------------
/00_HelloWorld/proxies.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/proxies",
3 | "proxies": {}
4 | }
5 |
--------------------------------------------------------------------------------
/2_ReadUnzipStore/proxies.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/proxies",
3 | "proxies": {}
4 | }
5 |
--------------------------------------------------------------------------------
/4_Flask/Flask_App/static/logo.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Garfinkel/GithubDataVisTool/HEAD/4_Flask/Flask_App/static/logo.JPG
--------------------------------------------------------------------------------
/4_Flask/Flask_App/static/slide_arch.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Garfinkel/GithubDataVisTool/HEAD/4_Flask/Flask_App/static/slide_arch.JPG
--------------------------------------------------------------------------------
/4_Flask/Flask_App/static/slide_arch.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Garfinkel/GithubDataVisTool/HEAD/4_Flask/Flask_App/static/slide_arch.PNG
--------------------------------------------------------------------------------
/3_ML/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ms-azuretools.vscode-azurefunctions",
4 | "ms-python.python"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/00_HelloWorld/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ms-azuretools.vscode-azurefunctions",
4 | "ms-python.python"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/0_HelloWorld/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ms-azuretools.vscode-azurefunctions",
4 | "ms-python.python"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/1_CallAPI/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ms-azuretools.vscode-azurefunctions",
4 | "ms-python.python"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/4_Flask/Flask_App/css/homepage.css:
--------------------------------------------------------------------------------
1 | .homepagebutton {
2 | width: 250px;
3 | }
4 | .is-something-fake {
5 | width: 20px;
6 | att2 : blank3
7 | }
--------------------------------------------------------------------------------
/2_ReadUnzipStore/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ms-azuretools.vscode-azurefunctions",
4 | "ms-python.python"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/3_ML/requirements.txt:
--------------------------------------------------------------------------------
1 | azure-functions
2 | pandas
3 | numpy
4 | ujson
5 | azure.cognitiveservices.language.textanalytics
6 | msrest
7 | azure-search-documents==1.0.0b3
8 |
--------------------------------------------------------------------------------
/3_ML/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "extensionBundle": {
4 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
5 | "version": "[1.*, 2.0.0)"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/1_CallAPI/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "extensionBundle": {
4 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
5 | "version": "[1.*, 2.0.0)"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/00_HelloWorld/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "extensionBundle": {
4 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
5 | "version": "[1.*, 2.0.0)"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/0_HelloWorld/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "extensionBundle": {
4 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
5 | "version": "[1.*, 2.0.0)"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/2_ReadUnzipStore/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0",
3 | "extensionBundle": {
4 | "id": "Microsoft.Azure.Functions.ExtensionBundle",
5 | "version": "[1.*, 2.0.0)"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Slides/Build Python Applications In Azure Faster With Visual Studio Code_v2_gh.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Garfinkel/GithubDataVisTool/HEAD/Slides/Build Python Applications In Azure Faster With Visual Studio Code_v2_gh.pptx
--------------------------------------------------------------------------------
/4_Flask/Flask_App/requirements.txt:
--------------------------------------------------------------------------------
1 | click==6.7
2 | Flask==1.0.2
3 | itsdangerous==0.24
4 | Jinja2==2.10
5 | MarkupSafe==1.0
6 | Werkzeug==0.14.1
7 | azure.cosmos==4.0.0b6
8 | azure-core==1.5.0
9 | azure-common==1.1.23
10 | pandas
--------------------------------------------------------------------------------
/2_ReadUnzipStore/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Attach to Python Functions",
6 | "type": "python",
7 | "request": "attach",
8 | "port": 8091,
9 | "preLaunchTask": "func: host start"
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/00_HelloWorld/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "azureFunctions.deploySubpath": ".",
3 | "azureFunctions.scmDoBuildDuringDeployment": true,
4 | "azureFunctions.pythonVenv": ".venv",
5 | "azureFunctions.projectLanguage": "Python",
6 | "azureFunctions.projectRuntime": "~2",
7 | "debug.internalConsoleOptions": "neverOpen"
8 | }
--------------------------------------------------------------------------------
/0_HelloWorld/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "azureFunctions.deploySubpath": ".",
3 | "azureFunctions.scmDoBuildDuringDeployment": true,
4 | "azureFunctions.pythonVenv": ".venv",
5 | "azureFunctions.projectLanguage": "Python",
6 | "azureFunctions.projectRuntime": "~2",
7 | "debug.internalConsoleOptions": "neverOpen"
8 | }
--------------------------------------------------------------------------------
/3_ML/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Attach to Python Functions",
6 | "type": "python",
7 | "request": "attach",
8 | "port": 9091,
9 | "preLaunchTask": "func: host start"
10 | }
11 | ]
12 | }
--------------------------------------------------------------------------------
/00_HelloWorld/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Attach to Python Functions",
6 | "type": "python",
7 | "request": "attach",
8 | "port": 9091,
9 | "preLaunchTask": "func: host start"
10 | }
11 | ]
12 | }
--------------------------------------------------------------------------------
/0_HelloWorld/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Attach to Python Functions",
6 | "type": "python",
7 | "request": "attach",
8 | "port": 9091,
9 | "preLaunchTask": "func: host start"
10 | }
11 | ]
12 | }
--------------------------------------------------------------------------------
/1_CallAPI/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Attach to Python Functions",
6 | "type": "python",
7 | "request": "attach",
8 | "port": 5091,
9 | "preLaunchTask": "func: host start"
10 | }
11 | ]
12 | }
--------------------------------------------------------------------------------
/4_Flask/Flask_App/README.md:
--------------------------------------------------------------------------------
1 | ## Contributing
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
4 |
--------------------------------------------------------------------------------
/1_CallAPI/DownloadStore/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "scriptFile": "__init__.py",
3 | "bindings": [
4 | {
5 | "authLevel": "admin",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "name": "req",
9 | "methods": [
10 | "get",
11 | "post"
12 | ]
13 | },
14 | {
15 | "type": "http",
16 | "direction": "out",
17 | "name": "$return"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/00_HelloWorld/HttpTrigger1/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "scriptFile": "__init__.py",
3 | "bindings": [
4 | {
5 | "authLevel": "function",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "name": "req",
9 | "methods": [
10 | "get",
11 | "post"
12 | ]
13 | },
14 | {
15 | "type": "http",
16 | "direction": "out",
17 | "name": "$return"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/0_HelloWorld/Build2020blank/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "scriptFile": "__init__.py",
3 | "bindings": [
4 | {
5 | "authLevel": "anonymous",
6 | "type": "httpTrigger",
7 | "direction": "in",
8 | "name": "req",
9 | "methods": [
10 | "get",
11 | "post"
12 | ]
13 | },
14 | {
15 | "type": "http",
16 | "direction": "out",
17 | "name": "$return"
18 | }
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/3_ML/cogservicesscript:
--------------------------------------------------------------------------------
1 | # Log into CLI (requires you to download az cli)
2 | az login
3 |
4 | # Create Resouce Group
5 | az group create --name ExampleRG --location westus (group already exists at this point)
6 |
7 | # Create Text Analytics Service
8 | az cognitiveservices account create --name ExampleName --resource-group ExampleRG --kind TextAnalytics --sku F0 --location westus
9 |
10 | #Get Keys
11 | az cognitiveservices account keys list --name ExampleName --resource-group ExampleRG
12 |
13 |
14 |
--------------------------------------------------------------------------------
/2_ReadUnzipStore/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "azureFunctions.deploySubpath": ".",
3 | "azureFunctions.scmDoBuildDuringDeployment": true,
4 | "azureFunctions.pythonVenv": ".venv",
5 | "azureFunctions.projectLanguage": "Python",
6 | "azureFunctions.projectRuntime": "~2",
7 | "debug.internalConsoleOptions": "neverOpen",
8 | "azureFunctions.templateFilter": "Verified",
9 | "python.pythonPath": ".venv\\Scripts\\python.exe",
10 | "python.linting.pylintEnabled": true,
11 | "python.linting.enabled": true
12 | }
--------------------------------------------------------------------------------
/3_ML/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "azureFunctions.templateFilter": "Verified",
3 | "azureFunctions.deploySubpath": ".",
4 | "azureFunctions.scmDoBuildDuringDeployment": true,
5 | "azureFunctions.pythonVenv": ".venv",
6 | "azureFunctions.projectLanguage": "Python",
7 | "azureFunctions.projectRuntime": "~2",
8 | "debug.internalConsoleOptions": "neverOpen",
9 | "python.pythonPath": ".venv\\Scripts\\python.exe",
10 | "python.linting.pylintEnabled": true,
11 | "python.linting.enabled": true
12 | }
--------------------------------------------------------------------------------
/1_CallAPI/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "azureFunctions.deploySubpath": ".",
3 | "azureFunctions.scmDoBuildDuringDeployment": true,
4 | "azureFunctions.pythonVenv": ".venv",
5 | "azureFunctions.projectLanguage": "Python",
6 | "azureFunctions.projectRuntime": "~2",
7 | "debug.internalConsoleOptions": "neverOpen",
8 | "azureFunctions.showPythonVenvWarning": true,
9 | "azureFunctions.createPythonVenv": true,
10 | "python.pythonPath": "c:\\Users\\nigarfin\\Documents\\Python Tooling Team\\Conferences\\Build2020\\demo\\1_CallAPI\\.venv\\Scripts\\python.exe"
11 | }
--------------------------------------------------------------------------------
/2_ReadUnzipStore/DownloadUnzipStore_GHData/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "scriptFile": "__init__.py",
3 | "bindings": [
4 | {
5 | "type": "blobTrigger",
6 | "direction": "in",
7 | "name": "inputblob",
8 | "connection": "build2020pyvsc_connectionstring",
9 | "path": "raw"
10 | },
11 | {
12 | "name": "outputdb",
13 | "type": "cosmosDB",
14 | "direction": "out",
15 | "databaseName": "primary",
16 | "collectionName": "raw",
17 | "leaseCollectionName": "leases",
18 | "createLeaseCollectionIfNotExists": true,
19 | "connectionStringSetting": "build2020pyvscdb_connectionstring",
20 | "createIfNotExists": true
21 | }
22 | ]
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/0_HelloWorld/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "type": "func",
6 | "command": "host start",
7 | "problemMatcher": "$func-watch",
8 | "isBackground": true,
9 | "dependsOn": "pipInstall"
10 | },
11 | {
12 | "label": "pipInstall",
13 | "type": "shell",
14 | "osx": {
15 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
16 | },
17 | "windows": {
18 | "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
19 | },
20 | "linux": {
21 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
22 | },
23 | "problemMatcher": []
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/1_CallAPI/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "type": "func",
6 | "command": "host start",
7 | "problemMatcher": "$func-watch",
8 | "isBackground": true,
9 | "dependsOn": "pipInstall"
10 | },
11 | {
12 | "label": "pipInstall",
13 | "type": "shell",
14 | "osx": {
15 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
16 | },
17 | "windows": {
18 | "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
19 | },
20 | "linux": {
21 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
22 | },
23 | "problemMatcher": []
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/00_HelloWorld/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "type": "func",
6 | "command": "host start",
7 | "problemMatcher": "$func-watch",
8 | "isBackground": true,
9 | "dependsOn": "pipInstall"
10 | },
11 | {
12 | "label": "pipInstall",
13 | "type": "shell",
14 | "osx": {
15 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
16 | },
17 | "windows": {
18 | "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
19 | },
20 | "linux": {
21 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
22 | },
23 | "problemMatcher": []
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/2_ReadUnzipStore/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "type": "func",
6 | "command": "host start",
7 | "problemMatcher": "$func-watch",
8 | "isBackground": true,
9 | "dependsOn": "pipInstall"
10 | },
11 | {
12 | "label": "pipInstall",
13 | "type": "shell",
14 | "osx": {
15 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
16 | },
17 | "windows": {
18 | "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
19 | },
20 | "linux": {
21 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
22 | },
23 | "problemMatcher": []
24 | }
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/00_HelloWorld/HttpTrigger1/__init__.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | import azure.functions as func
4 |
5 |
6 | def main(req: func.HttpRequest) -> func.HttpResponse:
7 | logging.info('Python HTTP trigger function processed a request.')
8 |
9 | name = req.params.get('name')
10 | if not name:
11 | try:
12 | req_body = req.get_json()
13 | except ValueError:
14 | pass
15 | else:
16 | name = req_body.get('name')
17 |
18 | if name:
19 | return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
20 | else:
21 | return func.HttpResponse(
22 | "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
23 | status_code=200
24 | )
25 |
--------------------------------------------------------------------------------
/0_HelloWorld/Build2020blank/__init__.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | import azure.functions as func
4 |
5 |
6 | def main(req: func.HttpRequest) -> func.HttpResponse:
7 | logging.info('Python HTTP trigger function processed a request.')
8 |
9 | name = req.params.get('name')
10 | if not name:
11 | try:
12 | req_body = req.get_json()
13 | except ValueError:
14 | pass
15 | else:
16 | name = req_body.get('name')
17 |
18 | if name:
19 | return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
20 | else:
21 | return func.HttpResponse(
22 | "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
23 | status_code=200
24 | )
25 |
--------------------------------------------------------------------------------
/3_ML/CosmosDB_Cog_Trigger/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "scriptFile": "__init__.py",
3 | "bindings": [
4 | {
5 | "type": "cosmosDBTrigger",
6 | "name": "documents",
7 | "direction": "in",
8 | "leaseCollectionName": "leases",
9 | "connectionStringSetting": "build2020pyvscdb_connectionstring",
10 | "databaseName": "primary",
11 | "collectionName": "raw",
12 | "createLeaseCollectionIfNotExists": true
13 | },
14 | {
15 | "name": "outdoc",
16 | "type": "cosmosDB",
17 | "direction": "out",
18 | "databaseName": "primary",
19 | "collectionName": "final",
20 | "leaseCollectionName": "leases",
21 | "createLeaseCollectionIfNotExists": true,
22 | "connectionStringSetting": "build2020pyvscdb_connectionstring",
23 | "createIfNotExists": true
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/4_Flask/Flask_App/templates/issueSummary.htm:
--------------------------------------------------------------------------------
1 | {% extends "./base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 |
Issue Details
7 |
8 | This page contains all details for a single issue
9 |
10 |
11 |
12 |
13 |
14 | Attribute
15 | Value
16 |
17 |
18 | {% for x in singleitem%}
19 |
20 |
21 | {{x}}
22 | {{singleitem[x]}}
23 |
24 | {% endfor %}
25 |
26 |
27 |
28 |
29 | {% endblock %}
--------------------------------------------------------------------------------
/3_ML/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "type": "func",
6 | "command": "host start",
7 | "problemMatcher": "$func-watch",
8 | "isBackground": true,
9 | "dependsOn": "pipInstall"
10 | },
11 | {
12 | "label": "pipInstall",
13 | "type": "shell",
14 | "osx": {
15 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
16 | },
17 | "windows": {
18 | "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
19 | },
20 | "linux": {
21 | "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
22 | },
23 | "problemMatcher": []
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/4_Flask/Flask_App/templates/issue.htm:
--------------------------------------------------------------------------------
1 | {% extends "./base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 |
IssueId Lookup
7 |
8 | Include the IssueId and RepoName to lookup invidual issues.
9 |
10 |
21 |
22 |
23 |
24 |
25 | {% endblock %}
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Nicolas Garfinkel
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/4_Flask/Flask_App/templates/repo.htm:
--------------------------------------------------------------------------------
1 | {% extends "./base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 |
Summary
7 |
8 | Enter the name of your repo, to return issue details.
9 |
10 |
28 |
29 |
30 |
31 | {% endblock %}
--------------------------------------------------------------------------------
/4_Flask/Flask_App/templates/keyphraseSummary.htm:
--------------------------------------------------------------------------------
1 | {% extends "./base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 |
Issue Details
7 |
This page contains all details for a single key phrase
8 |
9 |
10 |
11 | Id
12 | Issue
13 | Date
14 | Link
15 | KRs
16 |
17 |
18 | {% for item in output.itertuples() %}
19 |
20 |
21 | {{item.id}}
22 | {{item.issue_title}}
23 | {{item.created_datetime}}
24 | link to GH
25 | {{item.NER}}
26 |
27 |
28 | {% endfor %}
29 |
30 |
31 |
32 |
33 | {% endblock %}
--------------------------------------------------------------------------------
/4_Flask/Flask_App/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "appService.zipIgnorePattern": [
3 | "__pycache__{,/**}",
4 | "*.py[cod]",
5 | "*$py.class",
6 | ".Python{,/**}",
7 | "build{,/**}",
8 | "develop-eggs{,/**}",
9 | "dist{,/**}",
10 | "downloads{,/**}",
11 | "eggs{,/**}",
12 | ".eggs{,/**}",
13 | "lib{,/**}",
14 | "lib64{,/**}",
15 | "parts{,/**}",
16 | "sdist{,/**}",
17 | "var{,/**}",
18 | "wheels{,/**}",
19 | "share/python-wheels{,/**}",
20 | "*.egg-info{,/**}",
21 | ".installed.cfg",
22 | "*.egg",
23 | "MANIFEST",
24 | ".env{,/**}",
25 | ".venv{,/**}",
26 | "env{,/**}",
27 | "venv{,/**}",
28 | "ENV{,/**}",
29 | "env.bak{,/**}",
30 | "venv.bak{,/**}",
31 | ".vscode{,/**}"
32 | ],
33 | "appService.deploySubpath": "",
34 | "appService.defaultWebAppToDeploy": "/subscriptions/1163fbbe-27e7-4b0f-8466-195fe5417043/resourceGroups/build2020pyvscweb/providers/Microsoft.Web/sites/build2020pyvscweb",
35 | "python.pythonPath": "c:\\Users\\nigarfin\\Documents\\Python Tooling Team\\Conferences\\Build2020\\demo\\4_Flask\\python-docs-hello-world\\venv\\Scripts\\python.exe"
36 | }
--------------------------------------------------------------------------------
/4_Flask/Flask_App/templates/home.htm:
--------------------------------------------------------------------------------
1 | {% extends "./base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 |
Build Python apps in Azure faster with Visual Studio Code
7 |
9 |
10 |
11 |
12 |
13 |
Webapp Overview
14 |
17 |
About me : I was built as part of a BUILD 2020 talk to show off how productive you can be when you use VS Code to build apps in Azure! You can find the GitHub repo, and all sorts of resources by visiting the following link: aka.ms/Build2020pyvsc .
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | {% endblock %}
--------------------------------------------------------------------------------
/4_Flask/Flask_App/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 |
27 | # PyInstaller
28 | # Usually these files are written by a python script from a template
29 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
30 | *.manifest
31 | *.spec
32 |
33 | # Installer logs
34 | pip-log.txt
35 | pip-delete-this-directory.txt
36 |
37 | # Unit test / coverage reports
38 | htmlcov/
39 | .tox/
40 | .coverage
41 | .coverage.*
42 | .cache
43 | nosetests.xml
44 | coverage.xml
45 | *,cover
46 | .hypothesis/
47 |
48 | # Translations
49 | *.mo
50 | *.pot
51 |
52 | # Django stuff:
53 | *.log
54 | local_settings.py
55 |
56 | # Flask stuff:
57 | instance/
58 | .webassets-cache
59 |
60 | # Scrapy stuff:
61 | .scrapy
62 |
63 | # Sphinx documentation
64 | docs/_build/
65 |
66 | # PyBuilder
67 | target/
68 |
69 | # IPython Notebook
70 | .ipynb_checkpoints
71 |
72 | # pyenv
73 | .python-version
74 |
75 | # celery beat schedule file
76 | celerybeat-schedule
77 |
78 | # dotenv
79 | .env
80 |
81 | # virtualenv
82 | venv/
83 | ENV/
84 |
85 | # Spyder project settings
86 | .spyderproject
87 |
88 | # Rope project settings
89 | .ropeproject
90 |
91 | # Local Settings
92 | .dbkeys
93 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Build Python apps in Azure faster with Visual Studio Code
2 |
3 | Resources, and code for the BUILD 2020 live Q+A session "Build Python apps in Azure faster with Visual Studio Code" presented by Nicolas Garfinkel on May 2020.
4 |
5 | Slides can be found in this Github Repo
6 |
7 | **Resources**
8 | - Azure Functions: https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code?pivots=programming-language-python
9 | - Azure App Service: https://docs.microsoft.com/en-us/samples/azure-samples/python-docs-hello-world/python-flask-sample-for-azure-app-service-linux/
10 | - Cognitive Services: https://azure.microsoft.com/en-us/services/cognitive-services/
11 | - CosmosDB: https://azure.microsoft.com/en-us/services/cosmos-db/
12 | - Azure Blob Storage: https://azure.microsoft.com/en-us/services/storage/blobs/
13 |
14 | **Requirments**
15 | - Python 3.6/3.7: https://www.python.org/downloads/release/python-377/
16 | - Azure Subscription: https://aka.ms/pythonazurefree
17 | - VS Code: https://aka.ms/pythonvscode
18 | - VS Code Extensions - Install in product with the extensions tab (Azure Account extension, + Azure Services extensions)
19 |
20 | **Talk to us! Seriously!**
21 | - Join us on Discord: https://aka.ms/Build2020-PythonVSC
22 | - Tell us about your Python experience on Azure: https://aka.ms/Build2020-PythonAzure-Survey
23 |
24 | **Extensions** -- Download in Extensions tab of VSC
25 | - Azure Functions
26 | - Azure App Service
27 | - Azure CosmosDB
28 | - Azure Storage
29 |
--------------------------------------------------------------------------------
/1_CallAPI/DownloadStore/__init__.py:
--------------------------------------------------------------------------------
1 | import azure.functions as func
2 | from azure.storage.blob import BlobClient
3 | import os
4 | import logging
5 | import gzip
6 | import requests
7 |
8 | def main(req: func.HttpRequest):
9 | logging.info('Github Function triggered function processed a request.')
10 |
11 | # URL Input Parameters
12 | input_year = int(req.params.get('year'))
13 | input_month = int(req.params.get('month'))
14 | input_day = int(req.params.get('day'))
15 | input_hour = int(req.params.get('hour'))
16 |
17 | # Example : http://localhost:7071/api/DownloadStore?year=2020&month=05&day=11&hour=14
18 |
19 |
20 | # Call API passing in date parameters to obtain zip file
21 | domain = 'http://data.gharchive.org/'
22 | path = "{y}-{m:02d}-{d:02d}-{h}.json.gz"
23 | p = path.format(y=input_year, m=input_month, d=input_day, h=input_hour)
24 | uri = domain + p
25 | logging.info(f'Getting file for {uri}')
26 | r = requests.get(uri, stream=True)
27 |
28 | #Log Header Details
29 | logging.info(r.headers['Content-Length'])
30 |
31 | # Call Azure Python SDK, Upload API response
32 | logging.info(f'Uploading Starting - {p}')
33 | connection_string = os.environ["CONNECTION_STRING"]
34 |
35 | try:
36 | blob = BlobClient.from_connection_string(conn_str=connection_string, container_name='raw', blob_name=p)
37 | blob.upload_blob(r.content, overwrite = True)
38 | logging.info(f'Uploading Complete - {p}')
39 | except:
40 | logging.error(f'Upload Failure - {p}')
41 |
42 | return 'Function has finished running'
43 |
44 | # LOCAL : http://localhost:7071/api/DownloadStore?year=2020&month=05&day=11&hour=14
45 | # PARAMS : &year=2020&month=05&day=09&hour=17
--------------------------------------------------------------------------------
/4_Flask/Flask_App/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Python: Current File (Integrated Terminal)",
9 | "type": "python",
10 | "request": "launch",
11 | "program": "${file}",
12 | "console": "integratedTerminal"
13 | },
14 | {
15 | "name": "Python: Remote Attach",
16 | "type": "python",
17 | "request": "attach",
18 | "port": 5678,
19 | "host": "localhost",
20 | "pathMappings": [
21 | {
22 | "localRoot": "${workspaceFolder}",
23 | "remoteRoot": "."
24 | }
25 | ]
26 | },
27 | {
28 | "name": "Python: Module",
29 | "type": "python",
30 | "request": "launch",
31 | "module": "enter-your-module-name-here",
32 | "console": "integratedTerminal"
33 | },
34 | {
35 | "name": "Python: Django",
36 | "type": "python",
37 | "request": "launch",
38 | "program": "${workspaceFolder}/manage.py",
39 | "console": "integratedTerminal",
40 | "args": [
41 | "runserver",
42 | "--noreload",
43 | "--nothreading"
44 | ],
45 | "django": true
46 | },
47 | {
48 | "name": "Python: Flask",
49 | "type": "python",
50 | "request": "launch",
51 | "module": "flask",
52 | "env": {
53 | "FLASK_APP": "app.py"
54 | },
55 | "args": [
56 | "run",
57 | "--no-debugger",
58 | "--no-reload"
59 | ],
60 | "jinja": true
61 | },
62 | {
63 | "name": "Python: Current File (External Terminal)",
64 | "type": "python",
65 | "request": "launch",
66 | "program": "${file}",
67 | "console": "externalTerminal"
68 | }
69 | ]
70 | }
--------------------------------------------------------------------------------
/4_Flask/Flask_App/templates/repoSummary.htm:
--------------------------------------------------------------------------------
1 | {% extends "./base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 |
Overview
7 |
Results for Repo: {{overview_data['RepoName']}}
8 |
Repo ID: {{overview_data['RepoId']}}
9 |
Total Issues: {{overview_data['TotalIssues']}}
10 |
Most Recent: {{overview_data['MostRecent']}}
11 |
12 |
13 |
14 |
15 |
Top Key Phrases
16 |
17 |
18 |
19 | Key Phrase
20 | Count
21 | Pct_of_total
22 |
23 |
24 |
25 | {% for item in TopIssues.itertuples() %}
26 |
27 |
28 | {{item.NER}}
29 | {{item.Count}}
30 | {{item.Pct}}
31 |
32 | {% endfor %}
33 |
34 |
35 |
36 |
37 |
Most Recent Issues
38 |
39 |
40 |
41 | Id
42 | Issue
43 | Date
44 | Link
45 | KRs
46 |
47 |
48 | {% for mr_item in recentIssue.itertuples() %}
49 |
50 |
51 | {{mr_item.id}}
52 | {{mr_item.issue_title}}
53 | {{mr_item.created_datetime}}
54 | link to GH
55 | {{mr_item.NER}}
56 |
57 | {% endfor %}
58 |
59 |
60 |
61 |
62 | {% endblock %}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # Jupyter Notebook
76 | .ipynb_checkpoints
77 |
78 | # IPython
79 | profile_default/
80 | ipython_config.py
81 |
82 | # pyenv
83 | .python-version
84 |
85 | # pipenv
86 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
88 | # having no cross-platform support, pipenv may install dependencies that don’t work, or not
89 | # install all needed dependencies.
90 | #Pipfile.lock
91 |
92 | # celery beat schedule file
93 | celerybeat-schedule
94 |
95 | # SageMath parsed files
96 | *.sage.py
97 |
98 | # Environments
99 | .env
100 | .venv
101 | env/
102 | venv/
103 | ENV/
104 | env.bak/
105 | venv.bak/
106 |
107 | # Spyder project settings
108 | .spyderproject
109 | .spyproject
110 |
111 | # Rope project settings
112 | .ropeproject
113 |
114 | # mkdocs documentation
115 | /site
116 |
117 | # mypy
118 | .mypy_cache/
119 | .dmypy.json
120 | dmypy.json
121 |
122 | # Pyre type checker
123 | .pyre/
124 |
125 | # Azure Functions artifacts
126 | bin
127 | obj
128 | appsettings.json
129 | local.settings.json
130 | .python_packages
--------------------------------------------------------------------------------
/3_ML/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # Jupyter Notebook
76 | .ipynb_checkpoints
77 |
78 | # IPython
79 | profile_default/
80 | ipython_config.py
81 |
82 | # pyenv
83 | .python-version
84 |
85 | # pipenv
86 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
88 | # having no cross-platform support, pipenv may install dependencies that don’t work, or not
89 | # install all needed dependencies.
90 | #Pipfile.lock
91 |
92 | # celery beat schedule file
93 | celerybeat-schedule
94 |
95 | # SageMath parsed files
96 | *.sage.py
97 |
98 | # Environments
99 | .env
100 | .venv
101 | env/
102 | venv/
103 | ENV/
104 | env.bak/
105 | venv.bak/
106 |
107 | # Spyder project settings
108 | .spyderproject
109 | .spyproject
110 |
111 | # Rope project settings
112 | .ropeproject
113 |
114 | # mkdocs documentation
115 | /site
116 |
117 | # mypy
118 | .mypy_cache/
119 | .dmypy.json
120 | dmypy.json
121 |
122 | # Pyre type checker
123 | .pyre/
124 |
125 | # Azure Functions artifacts
126 | bin
127 | obj
128 | appsettings.json
129 | local.settings.json
130 | .python_packages
--------------------------------------------------------------------------------
/0_HelloWorld/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # Jupyter Notebook
76 | .ipynb_checkpoints
77 |
78 | # IPython
79 | profile_default/
80 | ipython_config.py
81 |
82 | # pyenv
83 | .python-version
84 |
85 | # pipenv
86 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
88 | # having no cross-platform support, pipenv may install dependencies that don’t work, or not
89 | # install all needed dependencies.
90 | #Pipfile.lock
91 |
92 | # celery beat schedule file
93 | celerybeat-schedule
94 |
95 | # SageMath parsed files
96 | *.sage.py
97 |
98 | # Environments
99 | .env
100 | .venv
101 | env/
102 | venv/
103 | ENV/
104 | env.bak/
105 | venv.bak/
106 |
107 | # Spyder project settings
108 | .spyderproject
109 | .spyproject
110 |
111 | # Rope project settings
112 | .ropeproject
113 |
114 | # mkdocs documentation
115 | /site
116 |
117 | # mypy
118 | .mypy_cache/
119 | .dmypy.json
120 | dmypy.json
121 |
122 | # Pyre type checker
123 | .pyre/
124 |
125 | # Azure Functions artifacts
126 | bin
127 | obj
128 | appsettings.json
129 | local.settings.json
130 | .python_packages
--------------------------------------------------------------------------------
/1_CallAPI/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # Jupyter Notebook
76 | .ipynb_checkpoints
77 |
78 | # IPython
79 | profile_default/
80 | ipython_config.py
81 |
82 | # pyenv
83 | .python-version
84 |
85 | # pipenv
86 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
88 | # having no cross-platform support, pipenv may install dependencies that don’t work, or not
89 | # install all needed dependencies.
90 | #Pipfile.lock
91 |
92 | # celery beat schedule file
93 | celerybeat-schedule
94 |
95 | # SageMath parsed files
96 | *.sage.py
97 |
98 | # Environments
99 | .env
100 | .venv
101 | env/
102 | venv/
103 | ENV/
104 | env.bak/
105 | venv.bak/
106 |
107 | # Spyder project settings
108 | .spyderproject
109 | .spyproject
110 |
111 | # Rope project settings
112 | .ropeproject
113 |
114 | # mkdocs documentation
115 | /site
116 |
117 | # mypy
118 | .mypy_cache/
119 | .dmypy.json
120 | dmypy.json
121 |
122 | # Pyre type checker
123 | .pyre/
124 |
125 | # Azure Functions artifacts
126 | bin
127 | obj
128 | appsettings.json
129 | local.settings.json
130 | .python_packages
--------------------------------------------------------------------------------
/00_HelloWorld/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # Jupyter Notebook
76 | .ipynb_checkpoints
77 |
78 | # IPython
79 | profile_default/
80 | ipython_config.py
81 |
82 | # pyenv
83 | .python-version
84 |
85 | # pipenv
86 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
88 | # having no cross-platform support, pipenv may install dependencies that don’t work, or not
89 | # install all needed dependencies.
90 | #Pipfile.lock
91 |
92 | # celery beat schedule file
93 | celerybeat-schedule
94 |
95 | # SageMath parsed files
96 | *.sage.py
97 |
98 | # Environments
99 | .env
100 | .venv
101 | env/
102 | venv/
103 | ENV/
104 | env.bak/
105 | venv.bak/
106 |
107 | # Spyder project settings
108 | .spyderproject
109 | .spyproject
110 |
111 | # Rope project settings
112 | .ropeproject
113 |
114 | # mkdocs documentation
115 | /site
116 |
117 | # mypy
118 | .mypy_cache/
119 | .dmypy.json
120 | dmypy.json
121 |
122 | # Pyre type checker
123 | .pyre/
124 |
125 | # Azure Functions artifacts
126 | bin
127 | obj
128 | appsettings.json
129 | local.settings.json
130 | .python_packages
--------------------------------------------------------------------------------
/2_ReadUnzipStore/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # Jupyter Notebook
76 | .ipynb_checkpoints
77 |
78 | # IPython
79 | profile_default/
80 | ipython_config.py
81 |
82 | # pyenv
83 | .python-version
84 |
85 | # pipenv
86 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
88 | # having no cross-platform support, pipenv may install dependencies that don’t work, or not
89 | # install all needed dependencies.
90 | #Pipfile.lock
91 |
92 | # celery beat schedule file
93 | celerybeat-schedule
94 |
95 | # SageMath parsed files
96 | *.sage.py
97 |
98 | # Environments
99 | .env
100 | .venv
101 | env/
102 | venv/
103 | ENV/
104 | env.bak/
105 | venv.bak/
106 |
107 | # Spyder project settings
108 | .spyderproject
109 | .spyproject
110 |
111 | # Rope project settings
112 | .ropeproject
113 |
114 | # mkdocs documentation
115 | /site
116 |
117 | # mypy
118 | .mypy_cache/
119 | .dmypy.json
120 | dmypy.json
121 |
122 | # Pyre type checker
123 | .pyre/
124 |
125 | # Azure Functions artifacts
126 | bin
127 | obj
128 | appsettings.json
129 | local.settings.json
130 | .python_packages
--------------------------------------------------------------------------------
/2_ReadUnzipStore/DownloadUnzipStore_GHData/__init__.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import azure.functions as func
3 | import gzip
4 | import json
5 | import datetime as dt
6 | import time as t
7 |
8 | # Blob Trigger - When a file is uploaded to my blob folder (raw). Defined in the functions.json file.
9 | # On Trigger ->
10 | # *Read GZIP, Unzip file and turn into JSON
11 | # *Filter data to 'new issues' only
12 | # *Shape data to meet our requirements
13 | # *Store new issues in CosmosDB DBs
14 |
15 |
16 | def main(inputblob: func.InputStream, outputdb: func.Out[func.Document]):
17 | logging.info('Data uploaded to raw Blob Storage, function processing a new request.')
18 | t.sleep(45)
19 |
20 | # Store output in variable Data as JSON
21 | with gzip.open(inputblob) as lines:
22 | data = [json.loads(i) for i in lines]
23 |
24 | # Create Doc List for batch upload
25 | NewEventList = func.DocumentList()
26 |
27 | # Empty variables
28 | NER = []
29 | count = 0
30 |
31 | #Log number of records
32 | records_count = str(len(data))
33 | logging.info(f'All Records: {records_count}')
34 |
35 | # Format records for CosmosDB Insertion
36 | for event in data:
37 |
38 | # filter to only issue-related events
39 | if "Issue" in event["type"]:
40 |
41 | # Filter to 'New Issues' only
42 | if event["payload"]["issue"]["comments"] == 0 :
43 |
44 | #Count # of new records in loop
45 | count += 1
46 |
47 | # Reshape Data + Store Record
48 | new_eventrecord = {
49 | "id" : event["id"],
50 | "issue_id" : event["payload"]["issue"]["id"],
51 | "issue_title" : event["payload"]["issue"]["title"],
52 | "issue_num" : event["payload"]["issue"]["number"],
53 | "repo_id" : event["repo"]["id"],
54 | "repo_name" : event["repo"]["name"].rsplit('/',1)[1],
55 | "created_datetime" : event["created_at"],
56 | "lastupdated_datetime" : event["created_at"],
57 | "issue_url" : event["payload"]["issue"]["html_url"],
58 | "last_state" : event["payload"]["action"],
59 | "NER" : NER,
60 | "json" : event
61 | }
62 |
63 | #Append Record to list of CosmosDB events for batch
64 | NewEventList.append(func.Document.from_dict(new_eventrecord))
65 |
66 | # If Issue != New, do nothing
67 | else:
68 | pass
69 |
70 |
71 | #if event type != Issue, do nothing
72 | else:
73 | pass
74 |
75 |
76 | t.sleep(5)
77 | outputdb.set(NewEventList)
78 | logging.info(f'Total Record Count | New Issue Creation Records: {str(count)}')
--------------------------------------------------------------------------------
/4_Flask/Flask_App/app.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, render_template, request, redirect, url_for
2 | from cosmosfunc.cosmos import DBSingleIssueQuery, DBQuery_AllIssueByRepoName, DBToDF, RepoWeeklyStats, RepoTopPhrases, DBSingleIssueLookup
3 | import pandas as pd
4 |
5 | app = Flask(__name__)
6 |
7 | @app.route('/')
8 | def home():
9 | return render_template('home.htm')
10 |
11 | @app.route('/repo')
12 | def repo():
13 | return render_template('repo.htm')
14 |
15 | @app.route('/r/')
16 | def repo_details(name):
17 |
18 | # Pulls all issues for a given repo.
19 | # Helper method from 'cosmosfunc' folder
20 | BaseItems = DBQuery_AllIssueByRepoName(name)
21 | df = DBToDF(BaseItems)
22 |
23 | # Calculate for overview
24 | TotalIssues = df['id'].count()
25 | RepoId = df['repo_id'][0]
26 | RepoName = df['repo_name'][0]
27 | MostRecent = df['lastupdated_datetime'].max()
28 | overview_data = {
29 | 'RepoName' : RepoName,
30 | 'RepoId' : RepoId,
31 | 'TotalIssues' : TotalIssues,
32 | 'MostRecent' : MostRecent
33 | }
34 |
35 | # Calculate top key phrases
36 | df_TopIssues = RepoTopPhrases(df)
37 | df_TopIssues['Pct'] = round(df_TopIssues['Count'] / TotalIssues,2)
38 | df_TopIssues = df_TopIssues.head(10)
39 | df_TopIssues['RepoName'] = RepoName
40 |
41 |
42 | # Calculate most recent
43 | columns = ['id','issue_title','created_datetime','issue_url','NER','repo_name']
44 | df_mostrecent = df[columns]
45 | df_mostrecent = df_mostrecent.sort_values('created_datetime',ascending = 0).head(10)
46 |
47 | return render_template('repoSummary.htm',overview_data = overview_data, recentIssue=df_mostrecent, TopIssues=df_TopIssues)
48 |
49 | @app.route('/repoSummary',methods = ['POST', 'GET'])
50 | def repoSummary():
51 | if request.method == 'POST':
52 | result = request.form
53 | return redirect(f"r/{result['RepoName']}", code=301)
54 |
55 | @app.route('/issue')
56 | def issue():
57 | return render_template('issue.htm')
58 |
59 | @app.route('/issueSummary',methods = ['POST', 'GET'])
60 | def issuesummary():
61 | if request.method == 'POST':
62 | result = request.form
63 | return redirect(f"r/{result['RepoName']}/i/{result['IssueId']}", code=301)
64 |
65 | @app.route('/r//i/')
66 | def issuedeepdive(reponame, issueid):
67 | results = DBSingleIssueLookup(IssueItemId=issueid,repoName=reponame)
68 | return render_template('issueSummary.htm',singleitem = results)
69 |
70 | @app.route('/r//kp/')
71 | def keyphrasedeepdive(reponame, keyphrase):
72 |
73 | # Query DB for Repo Items
74 | BaseItems = DBQuery_AllIssueByRepoName(reponame)
75 | df = DBToDF(BaseItems)
76 |
77 | # Trim DF
78 | columns = ['id','issue_title','created_datetime','issue_url','NER','repo_name']
79 | df_keyphrase = df[columns]
80 |
81 | # Filter to KeyPhrase
82 | filter = keyphrase
83 | df_keyphrase = df_keyphrase[df_keyphrase['NER'].str.contains(filter, regex=False)]
84 | df_keyphrase = df_keyphrase.sort_values('created_datetime',ascending = 0)
85 | return render_template('keyphraseSummary.htm',output = df_keyphrase)
86 |
87 | if __name__ == '__main__':
88 | app.run()
89 |
90 |
--------------------------------------------------------------------------------
/3_ML/CosmosDB_Cog_Trigger/__init__.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import os, requests, uuid, json
3 | import azure.functions as func
4 | from azure.cognitiveservices.language.textanalytics import TextAnalyticsClient
5 | from msrest.authentication import CognitiveServicesCredentials
6 |
7 | def main(documents: func.DocumentList, outdoc: func.Out[func.Document]):
8 | if documents:
9 | logging.info('Total Documents: %s', str(len(documents)))
10 |
11 |
12 | # Grab Env Variables
13 | # Local Development = local.settings.json
14 | # In Production = application settings in Azure
15 | Cognitive_Endpoint = os.environ['Cognitive_Endpoint']
16 | Cognitive_Key = os.environ['Cognitive_Key']
17 |
18 | # SDK Auth Flow
19 | credentials = CognitiveServicesCredentials(Cognitive_Key)
20 | text_analytics = TextAnalyticsClient(endpoint=Cognitive_Endpoint, credentials=credentials)
21 |
22 | # Create Doc List to append each doc to
23 | eventlist = func.DocumentList()
24 |
25 | # Set Batch Variables
26 | batch_size = 100
27 | batch_job = []
28 | computed_batches = []
29 |
30 |
31 | # look through every issue, filter to issue creation and set variables
32 | #check NER to avoid recursive loop
33 | for documents_items in documents:
34 | if len(documents_items["NER"]) == 0:
35 | eventId = documents_items["id"]
36 | IssueTitle = documents_items["issue_title"]
37 |
38 | #Create dict to pass to cognitive service issue titles
39 | doc_phrase_dict = {
40 | "id": eventId,
41 | "language": "en",
42 | "text": IssueTitle
43 | }
44 |
45 | # Append to batch_job for batch call
46 | batch_job.append(doc_phrase_dict)
47 |
48 | # Call API every 100 docs or we reach the end of the document list
49 | if len(batch_job)>=batch_size or eventId == documents[-1]["id"]:
50 |
51 | # Pass Batch to SDK
52 | response = text_analytics.key_phrases(documents=batch_job)
53 |
54 | # Loop through each item and update the original document
55 | for response_items in response.documents:
56 |
57 | # Apply NER findings back to each document
58 | computed_batches.append(response_items)
59 |
60 |
61 | # Now we loop through the original list and join the NER cells back
62 | for documents_items in documents:
63 | if len(documents_items["NER"]) == 0:
64 | for x in computed_batches:
65 | if x.id == documents_items["id"]:
66 |
67 | # Update NER and append to list
68 | documents_items["NER"] = x.key_phrases
69 | eventlist.append(func.Document.from_dict(documents_items))
70 |
71 | # Delete item from computed batches
72 | # HELP! Can't figure out!
73 | # want to do something like: del computed_batches[x.id]
74 |
75 |
76 |
77 | ## Set the DocumentList to outdoc to store into CosmosDB using CosmosDB output binding
78 | logging.info("Item Count: %s" % (len(eventlist)))
79 | outdoc.set(eventlist)
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/4_Flask/Flask_App/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Document
10 |
11 |
12 |
13 |
14 |
15 |
26 |
27 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | {% block content %}
71 | {% endblock %}
72 |
73 |
74 |
75 |
82 |
109 |
110 |
--------------------------------------------------------------------------------
/4_Flask/Flask_App/cosmosfunc/cosmos.py:
--------------------------------------------------------------------------------
1 | from azure.cosmos import CosmosClient, PartitionKey, errors
2 | import azure.cosmos.cosmos_client as cosmos_client
3 | import json
4 | import pandas as pd
5 | import datetime as dt
6 | from collections import Counter
7 |
8 | ### Establish connection string with DB ###
9 | import os
10 |
11 | def connectionstring():
12 |
13 | HOST = os.environ["AccountEndpoint"]
14 | MasterKey = os.environ["AccountKey"]
15 | CosmosDB_db = os.environ["Database"]
16 | CosmosDB_container = os.environ["Container"]
17 |
18 | # Initialize the Cosmos client
19 | client = cosmos_client.CosmosClient(HOST, {'masterKey': MasterKey})
20 |
21 | #Grab DB + Container client
22 | db_client = client.get_database_client(CosmosDB_db)
23 | container = db_client.get_container_client(container=CosmosDB_container)
24 |
25 | return container
26 |
27 |
28 | ### Query DB for all items in a given repo by Id ###
29 | def DBQuery_AllIssueByRepoId(repo_id):
30 |
31 | container = connectionstring()
32 |
33 | #Query container
34 | allitems = container.query_items(
35 | query="SELECT * FROM table2 f WHERE f.NER <> [] AND f.repo_id = @id",
36 | parameters=[{ "name":"@id", "value": repo_id}],
37 | enable_cross_partition_query=True)
38 |
39 | return allitems
40 |
41 | ### Query DB for all items in a given repo by name ###
42 | def DBQuery_AllIssueByRepoName(repo_name):
43 |
44 | container = connectionstring()
45 |
46 | #Query container
47 | allitems = container.query_items(
48 | query="SELECT * FROM table2 f WHERE f.NER <> [] AND f.repo_name = @id",
49 | parameters=[{ "name":"@id", "value": repo_name}],
50 | enable_cross_partition_query=True)
51 |
52 | return allitems
53 |
54 |
55 | ### Convert query results into DF ###
56 | def DBToDF(itemsFromQuery):
57 |
58 | result_list = []
59 | for item_DBToDF in itemsFromQuery:
60 |
61 | # Reformat datetime to startofweek
62 | try:
63 | issuedate = dt.datetime.strptime(item_DBToDF["created_datetime"],"%Y-%m-%dT%H:%M:%SZ")
64 | startofweek = dt.datetime.strftime(issuedate - dt.timedelta(days=issuedate.weekday()),"%Y-%m-%d")
65 | item_DBToDF["created_datetime"] = str(startofweek)
66 | except: pass
67 |
68 |
69 | # Append to empty list
70 | result_list.append(item_DBToDF)
71 |
72 | # Drop results into dataframe
73 | df = pd.DataFrame.from_records(result_list)
74 | #df = df.drop_duplicates()
75 | return df
76 |
77 |
78 | ### Count issues by week from DF ###
79 | def RepoWeeklyStats(df_input):
80 |
81 | # Count issues per week #
82 | issues_per_week = df_input.groupby('created_datetime').count()
83 |
84 | return issues_per_week
85 |
86 |
87 | ### Count issues by key phrase from DF ###
88 | def RepoTopPhrases(df_input):
89 |
90 |
91 | # Create list of all key issues
92 | key_phrases = []
93 | for x,y in df_input.iterrows():
94 | for NER_entities in y['NER']:
95 | key_phrases.append(NER_entities)
96 |
97 | # count occurance and turn into dict
98 | c = dict(Counter(key_phrases))
99 |
100 | # turn count into df
101 | df_final = pd.DataFrame(list(c.items()), columns=['NER', 'Count']).sort_values("Count",ascending=False)
102 |
103 | return df_final
104 |
105 |
106 | ### Query for a single item ###
107 | def DBSingleIssueQuery(IssueItemId):
108 | container = connectionstring()
109 |
110 | #Query container
111 | SI_items = container.query_items(
112 | query="SELECT Top 1 * FROM FinalDB i WHERE i.id=@id",
113 | parameters=[{ "name":"@id", "value": IssueItemId}],
114 | enable_cross_partition_query=True)
115 |
116 | # Loop through results, and assign variables
117 | for SI_record in SI_items:
118 | base = SI_record
119 |
120 | return base
121 |
122 | def DBSingleIssueLookup(IssueItemId, repoName):
123 | container = connectionstring()
124 | item_response = container.read_item(item=IssueItemId, partition_key=repoName)
125 |
126 | return item_response
127 |
128 |
129 | ##################
130 | ## HOW TO QUERY ##
131 |
132 | # 1) Query for single item
133 | #SingleIssueResult = DBSingleIssueQuery('10459kk064042')
134 |
135 | # 2) Query for Repo aggregate data
136 |
137 | # Return DF
138 | #BaseItems = DBQuery_AllIssueByRepo(73786682)
139 | #df = DBToDF(BaseItems)
140 | #TopIssues = RepoTopPhrases(df)
141 |
142 | # Run Calcs
143 | #WeeklyIssueCount = RepoWeeklyStats(df)
144 | #TopIssues = RepoTopPhrases(df,500)
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------