{"id":24562567,"url":"https://github.com/humanbrainproject/ebrains-storage","last_synced_at":"2025-04-19T17:42:52.110Z","repository":{"id":41201521,"uuid":"294723046","full_name":"HumanBrainProject/ebrains-storage","owner":"HumanBrainProject","description":"Python client interface for EBRAINS Collaboratory Drive (Seafile) and Bucket (data-proxy) storage","archived":false,"fork":false,"pushed_at":"2024-11-05T09:30:15.000Z","size":384,"stargazers_count":10,"open_issues_count":12,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-18T04:47:20.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HumanBrainProject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-11T14:51:13.000Z","updated_at":"2024-11-22T09:09:46.000Z","dependencies_parsed_at":"2024-02-20T10:28:17.190Z","dependency_job_id":"34b5ca59-cdff-47b4-935e-2e5e2cdfcd9d","html_url":"https://github.com/HumanBrainProject/ebrains-storage","commit_stats":{"total_commits":77,"total_committers":9,"mean_commits":8.555555555555555,"dds":0.7402597402597403,"last_synced_commit":"b5282fa19f49b44c4f1db8e84f0c9fa2489773bf"},"previous_names":["humanbrainproject/ebrains-drive"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanBrainProject%2Febrains-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanBrainProject%2Febrains-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanBrainProject%2Febrains-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HumanBrainProject%2Febrains-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HumanBrainProject","download_url":"https://codeload.github.com/HumanBrainProject/ebrains-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249751621,"owners_count":21320343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-23T09:16:17.689Z","updated_at":"2025-04-19T17:42:52.092Z","avatar_url":"https://github.com/HumanBrainProject.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"ebrains_storage\n==============\n\nPython client interface for EBRAINS Collaboratory Drive (Seafile) and Bucket (Data-Proxy) storage.\n\n\nOriginal implementation source:\nhttps://github.com/haiwen/python-seafile\nby Shuai Lin (linshuai2012@gmail.com)\n\n\nUpdated for integration with HBP v2 Collaboratory's Seafile storage\nby Shailesh Appukuttan (appukuttan.shailesh@gmail.com)\n\n\nDocumentation: https://github.com/HumanBrainProject/ebrains-drive/blob/master/doc.md\n\nInstallation: `pip install ebrains_drive`\n\n\nExample usage (refer to docs for more):\n\n```python\n    # 1. Import module\n    import ebrains_drive\n\n    # 2. Create client object\n    # 2.1 either via\n    client = ebrains_drive.connect('hbp_username', 'password')\n    # 2.2 or via\n    from ebrains_drive.client import DriveApiClient\n    client = DriveApiClient(username=\"hbp_username\", password=\"password\")\n\n    \n    # 3. Working with Collab drives (libraries / repos)\n    # 3.1 Get list of all libraries that user has access to\n    list_repos =  client.repos.list_repos()\n    # 3.2 Get info of specific library\n    repo_obj = client.repos.get_repo('0fee1620-062d-4643-865b-951de1eee355')\n    print(repo_obj.__dict__)\n\n    # 4. Working with directories\n    # 4.1 Get info of a directory \n    repo_obj = client.repos.get_repo('0fee1620-062d-4643-865b-951de1eee355')\n    dir_obj = repo_obj.get_dir('/') # specify dir path; '/' signifies root directory\n    print(dir_obj.__dict__)\n    # 4.2 Get contents of directory\n    dir_obj.ls()\n\n\n    # 5. Working with files\n    # 5.1 Get info of a file \n    repo_obj = client.repos.get_repo('0fee1620-062d-4643-865b-951de1eee355')\n    file_obj = repo_obj.get_file('/sample-latest.csv') # specify file path\n    print(file_obj.__dict__)\n    # 5.2 Get file content\n    file_content = file_obj.get_content()\n    print(file_content)\n```\n\n## Experimental support for data-proxy\n\nOriginal implementation from Bjorn Kindler \u0026 Jan Fousek.\n\nExample Usage:\n\n### Access collab bucket\n\n```python\n    from ebrains_drive import BucketApiClient\n\n    # username/password not supported for bucket yet\n    client = BucketApiClient(token=\"ey...\")\n\n    # access existing bucket\n    bucket = client.buckets.get_bucket(\"existing_collab_name\")\n\n    # or create a new collab + bucket\n    bucket = client.create_new(\"new_collab_name\")\n\n    # upload new file\n    bucket.upload(\"/home/jovyan/test.txt\", \"test/foobar.txt\")\n\n    # Or upload from from in memory:\n    from io import StringIO\n    fh = StringIO()\n    fh.write(\"hello world\")\n    fh.seek(0)\n    bucket.upload(fh, \"test/foobar2.txt\")\n\n    # it seems newly uplaoded file will **NOT** be available immediately. Sleep for x seconds?\n    from time import sleep\n    sleep(1)\n\n    # list the contents\n    files = [f for f in bucket.ls(prefix=\"test\")]\n\n    # get the uploaded file\n    file_handle = bucket.get_file(\"foobar.txt\")\n    file_content = file_handle.get_content()\n\n    # delete a bucket (n.b. this will **NOT** delete the collab!)\n    client.delete_bucket(\"new_bucket_name\")\n```\n\nRead access of public buckets can be done without supplying a token:\n\n```python\n\n    from ebrains_drive import BucketApiClient\n    \n    # anonymous client only has read access to public buckets\n    anon_client = BucketApiClient()\n    public_bucket = anon_client.buckets.get_bucket(\"reference-atlas-data\")\n    \n    # list all files under static/\n    files = public_bucket.ls(prefix=\"static\")\n    print([f.name for f in files])\n\n```\n\n### Access datasets (e.g. HDG datasets)\n\n```python\n    from ebrains_drive import BucketApiClient\n    client = BucketApiClient(token=\"ey...\")\n\n    # access dataset bucket\n    # setting requeste_access = True will start the relevant access-request-flow when accessing HDG datasets\n    bucket = client.buckets.get_dataset(\"existing_dataset_id\", request_access=True)\n\n    # list the contents\n    files = [f for f in bucket.ls(prefix=\"path/to/somewhere/foo\")]\n\n    # get a file content\n    file_handle = bucket.get_file(\"path/to/somewhere/foobar.txt\")\n    file_content = file_handle.get_content()\n\n```\n\n\u003cdiv\u003e\u003cimg src=\"https://raw.githubusercontent.com/HumanBrainProject/ebrains-drive/master/eu_logo.jpg\" alt=\"EU Logo\" width=\"15%\" align=\"right\"\u003e\u003c/div\u003e\n\n### ACKNOWLEDGEMENTS\nThis open source software code was developed in part in the Human Brain Project, funded from the European Union's Horizon 2020 Framework Programme for Research and Innovation under Specific Grant Agreements No. 720270,  No. 785907, and No. 945539 (Human Brain Project SGA1, SGA2 and SGA3), and by the European Union's Research and Innovation Program Horizon Europe Grant Agreement No. 101147319 (EBRAINS 2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanbrainproject%2Febrains-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumanbrainproject%2Febrains-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanbrainproject%2Febrains-storage/lists"}