Python helpers to interact with GCP
Project description
Wrap essential Google Cloud Platform functions to a python API
Set project credentials and list VM's by prefix
import os
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "/Users/vadimskritskii/PycharmProjects/report/gcp/rock-embassy-279812-b252be8804df.json"
os.environ['FROM_LOCAL'] = 'false'
os.environ['GCP_BUCKET'] = 'bucket_name'
from python_wrap_gcp import manage_instance
manage_instance.list_gcp_instances('INTERNAL_IP', prefix='cc-wiki')
Returns project VM's filtered by prefix as pandas.DataFrame
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
0 cc-wiki-1 us-central1-f e2-medium true 10.128.0.10 35.232.196.210 RUNNING
1 cc-wiki-2 us-central1-f e2-medium true 10.128.0.12 35.193.87.226 RUNNING
2 cc-wiki-3 us-central1-f e2-medium true 10.128.0.14 34.123.56.251 RUNNING
3 cc-wiki-4 us-central1-f e2-medium true 10.128.0.11 35.223.179.167 RUNNING
4 cc-wiki-5 us-central1-f e2-medium true 10.128.0.15 35.225.92.133 RUNNING
5 cc-wiki-6 us-central1-f e2-medium true 10.128.0.13 35.238.125.9 RUNNING```
Start all VM's by a prefix
manage_instance.manage_gcp_instance(action='start', prefix='cc-wiki')
[12:35:43.3]-[wrap_gcloud.py]-[wrap_gcloud_action]-[start: us-central1-f: cc-wiki-1,cc-wiki-2,cc-wiki-3,cc-wiki-4,cc-wiki-5,cc-wiki-6]-[I]-[9520cb]
Abstraction interface to read/write data either locally or on GCP
Load data from the bucket
import json
from python_wrap_gcp import io
data = json.loads(io.emulate_open("gs://meely-inventory/data/context.json"))
# alternatively
from python_wrap_gcp.reload_data import load_gcs_file
data, time_data_updated = load_gcs_file("gs://meely-inventory/data/context.json")
Save data locally
import json, os
from python_wrap_gcp import io
os.environ['TO_LOCAL'] = 'true'
context = {"hello": "witam",
"world": "świat"}
io.emulate_open("~/Desktop/context.json", method='wb', data=context)
Create VM's by creating a template & setting VM replicas
from meely_crawl.docs import config
from python_wrap_gcp.configure_gcp import configure
configure_gcp = configure.Configure(config.Path, config.GCPConfig)
configure_gcp.set_up()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-wrap-gcp-0.0.12.tar.gz
(11.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python-wrap-gcp-0.0.12.tar.gz.
File metadata
- Download URL: python-wrap-gcp-0.0.12.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.36.1 importlib-metadata/4.11.3 keyring/18.0.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa56b860fd272fe3ff820c20fecdf51e193fe4ea558d2196a98703b9a298f76
|
|
| MD5 |
d5073bcf4f8f4c2aeff8c803ba2aa15c
|
|
| BLAKE2b-256 |
aae59b23663c15e2494e33b6f3499e2aeebfd9d287b594d755c2572ac667ba26
|
File details
Details for the file python_wrap_gcp-0.0.12-py3-none-any.whl.
File metadata
- Download URL: python_wrap_gcp-0.0.12-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.36.1 importlib-metadata/4.11.3 keyring/18.0.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37ca80c064c5e5d534739cd26244b52665861e8cff049b738ed26422a166ceae
|
|
| MD5 |
c37072cb350a10b7af47d3b5b9cd7cb4
|
|
| BLAKE2b-256 |
c9d71a63374f36d2c0157f06c44e88395eebe6c5750f8887ff62b553cb744c96
|