blob-mounting-helper-utility


Nameblob-mounting-helper-utility JSON
Version 1.1.4 PyPI version JSON
download
home_page
SummaryBlob mapping utility for easy translation between azure urls and local paths
upload_time2023-08-21 09:48:11
maintainer
docs_urlNone
authorIvica Matic
requires_python
license
keywords python azure blob mount
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Blob mapping utility

When your code needs to access many mapped blobs as a mounted folder, the utility to make translation between blob urls and filepaths easier was made.
It can be configured using the configuration json file.

You can also use this utility to download and uploads the blobs to/from the local file system without having to worry about the filepaths.

Configuration file example:

``` json
{
  "blob_mounting_configurations": [
    {
      "storage_account_name": "examplestagingstrgacc",
      "storage_account_url": "https://examplestagingstrgacc.blob.core.windows.net/",
      "container_name": "example-container-raw",
      "mount_point": "/mnt/example-container-raw"
    }
  ]
}
```

## How to use

```python
from blob_mounting_helper_utility import BlobMappingUtility
json_config_file = "blob_mapping_config.json"

# read the file into a dictionary
with open(json_config_file) as json_file:
    config = json.load(json_file)["blob_mounting_configurations"]

# create the utility object
blob_mapping_utility = BlobMappingUtility(config)

filepath1 = "/mnt/example-container-raw/cool_picture.png
blob_url = blob_mapping_utility.get_url_from_mounted_filepath(filepath1) # -> https://examplestagingstrgacc.blob.core.windows.net/example-container-raw/cool_picture.png

filepath2 = get_mounted_filepath_from_url(blob_url) # -> /mnt/example-container-raw/cool_picture.png
```

Also, if you were to pass the azure storage account key you can download and upload the blob to a local file path:

```python
from blob_mounting_helper_utility import BlobMappingUtility
json_config_file = "blob_mapping_config.json"

# read the file into a dictionary
with open(json_config_file) as json_file:
    config = json.load(json_file)["blob_mounting_configurations"]

azure_storage_account_key = "example_key"
# create the utility object
blob_mapping_utility = BlobMappingUtility(config, azure_storage_account_key)
url = "https://examplestagingstrgacc.blob.core.windows.net/example-container-raw/cool_picture.png"
blob_mapping_utility.download_blob(url) # -> Downloads the blob to the local file path "/mnt/example-container-raw/cool_picture.png"
local_filepath = "/mnt/example-container-raw/cool_picture.png"
do_something_to_file(local_filepath)
blob_mapping_utility.upload_blob(local_filepath) # -> Uploads the file to the blob url
blob_mapping_utility.cleanup_files() # cleans both downloaded and uploaded files from the local file system

```



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "blob-mounting-helper-utility",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,azure,blob,mount",
    "author": "Ivica Matic",
    "author_email": "<ivica.matic@spatialdays.com>",
    "download_url": "https://files.pythonhosted.org/packages/22/e8/09a27b4fb00fed393f02198d8a36e576a8b999ef97874f50f4e4a7d8ac73/blob_mounting_helper_utility-1.1.4.tar.gz",
    "platform": null,
    "description": "\n# Blob mapping utility\n\nWhen your code needs to access many mapped blobs as a mounted folder, the utility to make translation between blob urls and filepaths easier was made.\nIt can be configured using the configuration json file.\n\nYou can also use this utility to download and uploads the blobs to/from the local file system without having to worry about the filepaths.\n\nConfiguration file example:\n\n``` json\n{\n  \"blob_mounting_configurations\": [\n    {\n      \"storage_account_name\": \"examplestagingstrgacc\",\n      \"storage_account_url\": \"https://examplestagingstrgacc.blob.core.windows.net/\",\n      \"container_name\": \"example-container-raw\",\n      \"mount_point\": \"/mnt/example-container-raw\"\n    }\n  ]\n}\n```\n\n## How to use\n\n```python\nfrom blob_mounting_helper_utility import BlobMappingUtility\njson_config_file = \"blob_mapping_config.json\"\n\n# read the file into a dictionary\nwith open(json_config_file) as json_file:\n    config = json.load(json_file)[\"blob_mounting_configurations\"]\n\n# create the utility object\nblob_mapping_utility = BlobMappingUtility(config)\n\nfilepath1 = \"/mnt/example-container-raw/cool_picture.png\nblob_url = blob_mapping_utility.get_url_from_mounted_filepath(filepath1) # -> https://examplestagingstrgacc.blob.core.windows.net/example-container-raw/cool_picture.png\n\nfilepath2 = get_mounted_filepath_from_url(blob_url) # -> /mnt/example-container-raw/cool_picture.png\n```\n\nAlso, if you were to pass the azure storage account key you can download and upload the blob to a local file path:\n\n```python\nfrom blob_mounting_helper_utility import BlobMappingUtility\njson_config_file = \"blob_mapping_config.json\"\n\n# read the file into a dictionary\nwith open(json_config_file) as json_file:\n    config = json.load(json_file)[\"blob_mounting_configurations\"]\n\nazure_storage_account_key = \"example_key\"\n# create the utility object\nblob_mapping_utility = BlobMappingUtility(config, azure_storage_account_key)\nurl = \"https://examplestagingstrgacc.blob.core.windows.net/example-container-raw/cool_picture.png\"\nblob_mapping_utility.download_blob(url) # -> Downloads the blob to the local file path \"/mnt/example-container-raw/cool_picture.png\"\nlocal_filepath = \"/mnt/example-container-raw/cool_picture.png\"\ndo_something_to_file(local_filepath)\nblob_mapping_utility.upload_blob(local_filepath) # -> Uploads the file to the blob url\nblob_mapping_utility.cleanup_files() # cleans both downloaded and uploaded files from the local file system\n\n```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Blob mapping utility for easy translation between azure urls and local paths",
    "version": "1.1.4",
    "project_urls": null,
    "split_keywords": [
        "python",
        "azure",
        "blob",
        "mount"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a35eb3d100f6297d5c1b4873387379a4089db6365baea76547ec02577e4d50b5",
                "md5": "7a37b17a01310df53a119b958dcff7c0",
                "sha256": "d554de9a91a4abf7ed2f3e48a9673aadade4a000839a6aea4d5973fa0412ec53"
            },
            "downloads": -1,
            "filename": "blob_mounting_helper_utility-1.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a37b17a01310df53a119b958dcff7c0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4753,
            "upload_time": "2023-08-21T09:48:10",
            "upload_time_iso_8601": "2023-08-21T09:48:10.389772Z",
            "url": "https://files.pythonhosted.org/packages/a3/5e/b3d100f6297d5c1b4873387379a4089db6365baea76547ec02577e4d50b5/blob_mounting_helper_utility-1.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22e809a27b4fb00fed393f02198d8a36e576a8b999ef97874f50f4e4a7d8ac73",
                "md5": "01c12e4a460d56686e0fe7b3b79b318e",
                "sha256": "f8fcb3de089aefa9c854a4f51aade364beaa8be3d356c69d7a54e9bbf4c67bfd"
            },
            "downloads": -1,
            "filename": "blob_mounting_helper_utility-1.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "01c12e4a460d56686e0fe7b3b79b318e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4340,
            "upload_time": "2023-08-21T09:48:11",
            "upload_time_iso_8601": "2023-08-21T09:48:11.906308Z",
            "url": "https://files.pythonhosted.org/packages/22/e8/09a27b4fb00fed393f02198d8a36e576a8b999ef97874f50f4e4a7d8ac73/blob_mounting_helper_utility-1.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-21 09:48:11",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "blob-mounting-helper-utility"
}
        
Elapsed time: 0.49132s