From ea9eb07b4b004de7c5223641b1cd86d8dba43cb6 Mon Sep 17 00:00:00 2001 From: peterVG <672121+peterVG@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:02:27 -0800 Subject: [PATCH 01/12] make dev env install its own section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0865fae..c2c36bc 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Note: this examples assumes you have a Powergate server running with an API avai Examples of more elaborated usage can be found in the [examples](./examples/) folder. -## Development +# Development Please read contribution [guidelines](CONTRIBUTING.md) before starting development. From 04432c6f16d9f9bcd23bedad0679f73dd2ab392c Mon Sep 17 00:00:00 2001 From: peterVG <672121+peterVG@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:03:17 -0800 Subject: [PATCH 02/12] Capitalize name and remove old HackFS link. --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c2c36bc..e657e7d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pygate gRPC client +# Pygate gRPC client [![CodeFactor](https://www.codefactor.io/repository/github/pygate/pygate-grpc/badge)](https://www.codefactor.io/repository/github/pygate/pygate-grpc) [![PyPI version](https://badge.fury.io/py/pygate-grpc.svg)](https://badge.fury.io/py/pygate-grpc) @@ -6,9 +6,7 @@ [![Downloads](https://pepy.tech/badge/pygate-grpc)](https://pepy.tech/project/pygate-grpc) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -A Python interface to [Textile](https://textile.io/)'s [Powergate](https://docs.textile.io/powergate/) [Filecoin](https://filecoin.io/) API - -Pygate is a [HackFS](https://hackfs.com/) project. See the project [website](http://pygate.tech) for more details. +A Python interface to [Textile](https://textile.io/)'s [Powergate](https://docs.textile.io/powergate/) [Filecoin](https://filecoin.io/) API. See the project [website](http://pygate.tech) for more details. ## Getting Started From 6081ce1cc1443176887d09108b50820e0d04ec7b Mon Sep 17 00:00:00 2001 From: peterVG <672121+peterVG@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:23:27 -0800 Subject: [PATCH 03/12] remove test PyPi reference --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e657e7d..911dd60 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A Python interface to [Textile](https://textile.io/)'s [Powergate](https://docs. ## Getting Started -You can get started using `pygate_grpc` by installing it through the test PyPi repository. +You can get started using `pygate_grpc` by installing it through the PyPi repository. ``` pip install pygate_grpc From 8574532d0a6f4ce119868bd999d52a030fd0a1dd Mon Sep 17 00:00:00 2001 From: peterVG <672121+peterVG@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:38:10 -0800 Subject: [PATCH 04/12] Change sections to match standard README style https://github.com/RichardLitt/standard-readme/blob/master/example-readmes/maximal-readme.md --- README.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 911dd60..3ebe7a4 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,11 @@ [![Downloads](https://pepy.tech/badge/pygate-grpc)](https://pepy.tech/project/pygate-grpc) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +## Background + A Python interface to [Textile](https://textile.io/)'s [Powergate](https://docs.textile.io/powergate/) [Filecoin](https://filecoin.io/) API. See the project [website](http://pygate.tech) for more details. -## Getting Started +## Install You can get started using `pygate_grpc` by installing it through the PyPi repository. @@ -36,7 +38,7 @@ Note: this examples assumes you have a Powergate server running with an API avai Examples of more elaborated usage can be found in the [examples](./examples/) folder. -# Development +# Contributing Please read contribution [guidelines](CONTRIBUTING.md) before starting development. @@ -104,15 +106,8 @@ Finally, to push the new version to git and trigger a new release action it is n git push origin main --tags ``` -## Authors - -* **Antreas Pogiatzis** -* **Wang Ge** -* **Peter Van Garderen** - +## License -See also the list of [contributors](https://github.com/pygate/pygate-gRPC/graphs/contributors) who participated in this project. +[MIT © Antreas Pogiatzis, Wang Ge, Peter Van Garderen, Aaron Sutula](LICENSE) -## License -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details From 5b3858a9b3a827839e92ec51c23364cf4280a9ee Mon Sep 17 00:00:00 2001 From: peterVG <672121+peterVG@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:38:55 -0800 Subject: [PATCH 05/12] Add Aaron to Copyright statement --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 8c41a1e..87ca3f4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ MIT License -Copyright (c) 2020 Peter Van Garderen, Antreas Pogiatzis, Wang Ge +Copyright (c) 2020 Antreas Pogiatzis, Wang Ge, Peter Van Garderen, Aaron Sutula Permission is hereby granted, free of charge, to any person obtaining a copy From 90ab8ebeefc8a408cd240d77fabeabea18aa6e60 Mon Sep 17 00:00:00 2001 From: peterVG <672121+peterVG@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:44:06 -0800 Subject: [PATCH 06/12] Make the SSL flag more explicit in example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ebe7a4..0e48e2e 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,14 @@ Here is a basic usage example of the pygate_grpc: ```python from pygate_grpc.client import PowerGateClient -client = PowerGateClient("127.0.0.1:5002", False) +client = PowerGateClient("127.0.0.1:5002", is_secure=False) build_info = client.build_info() ``` Simple as that! -Note: this examples assumes you have a Powergate server running with an API available at `127.0.0.1:5002`. See Textile's Powergate [Localnet](https://docs.textile.io/powergate/localnet/). +Note: this examples assumes you have a Powergate server running with an API available at `127.0.0.1:5002`. See Textile's Powergate [Localnet](https://docs.textile.io/powergate/localnet/). The `is_secure=False` flag indicates that SSL is not enabled on this server. Examples of more elaborated usage can be found in the [examples](./examples/) folder. From fdb531ef4c0d09c6adf5d3bfb1c0b4ec3703bb4e Mon Sep 17 00:00:00 2001 From: peterVG <672121+peterVG@users.noreply.github.com> Date: Sat, 21 Nov 2020 11:48:48 -0800 Subject: [PATCH 07/12] Add Git clone step to Contributing --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 0e48e2e..8e9d2cd 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,16 @@ Please read contribution [guidelines](CONTRIBUTING.md) before starting developme To setup your development environment make sure you have the following software: +- [Git](https://git-scm.com/) - [Python](https://www.python.org/downloads/release/python-370/) - [pip](https://pip.pypa.io/en/stable/installing/) - [pipenv](https://pypi.org/project/pipenv/) ( or run `pip install pipenv`) +## Clone the repository +``` +git clone https://github.com/pygate/pygate-gRPC.git +``` + ## Install dependencies Runtime and development dependencies can be installed in a new virtual environment automatically by running: From 500e26aa7ab480f8982066bcb6fbbad4fcf38734 Mon Sep 17 00:00:00 2001 From: peterVG <672121+peterVG@users.noreply.github.com> Date: Sat, 21 Nov 2020 12:17:29 -0800 Subject: [PATCH 08/12] Expand and re-order virtual env instructions --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8e9d2cd..3562289 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,14 @@ git clone https://github.com/pygate/pygate-gRPC.git ## Install dependencies -Runtime and development dependencies can be installed in a new virtual environment automatically by running: +The runtime and development dependencies can be installed in a new virtual environment automatically by running the following command in the project root directory: -NOTE: The `--dev` flag can be ommited if you only need runtime dependencies ``` pipenv install --dev ``` +NOTE: The `--dev` flag can be ommited if you only need runtime dependencies + ### **Using the virtual environment** To run any command through pipenv's virtual environment you can spawn a new virtual environment shell by running: From 6415f63471a2d637144b9dd08a81bfe83ddc056a Mon Sep 17 00:00:00 2001 From: Peter Van Garderen Date: Sun, 22 Nov 2020 14:44:11 -0800 Subject: [PATCH 09/12] remove example script output --- .gitignore | 4 +++- examples/testfile_copy.txt | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 examples/testfile_copy.txt diff --git a/.gitignore b/.gitignore index b767664..24de1e8 100644 --- a/.gitignore +++ b/.gitignore @@ -139,4 +139,6 @@ dmypy.json # Cython debug symbols cython_debug/ -.vscode \ No newline at end of file +.vscode + +examples/testfile_copy.txt \ No newline at end of file diff --git a/examples/testfile_copy.txt b/examples/testfile_copy.txt deleted file mode 100644 index 9944a9f..0000000 --- a/examples/testfile_copy.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test file \ No newline at end of file From f333328e5bc3649e9bf95491a2d6d816f4a00a9e Mon Sep 17 00:00:00 2001 From: Peter Van Garderen Date: Fri, 27 Nov 2020 12:54:28 -0800 Subject: [PATCH 10/12] use more descriptive name. add JOB ID to output. reformat. --- examples/apply_pull_file.py | 14 +++++--- examples/store_retrieve.py | 68 +++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 examples/store_retrieve.py diff --git a/examples/apply_pull_file.py b/examples/apply_pull_file.py index feef098..5b949d4 100644 --- a/examples/apply_pull_file.py +++ b/examples/apply_pull_file.py @@ -19,12 +19,18 @@ print("Staging testfile.txt to IPFS storage") path = Path(os.path.abspath(__file__)) staged_file = c.data.stage_file(path.parent / "testfile.txt", user.token) - print("Applying storage config...") + print("IPFS CID: " + staged_file.cid) # Apply the default storage config to the given file - c.config.apply(staged_file.cid, override=False, token=user.token) + print("Applying Filecoin storage config to CID...") + job = c.config.apply(staged_file.cid, override=False, token=user.token) + + # Report back the Job ID for the successful Filecoin storage job + print("File successfully added to Filecoin storage.") + print("Job ID: " + job.jobId) # Override push with another config + print("Applying new config settings to file...") addresses = c.wallet.addresses(user.token) wallet = addresses[0].address new_config = { @@ -53,10 +59,10 @@ print(check) # Get the data back - print("Retrieving file " + staged_file.cid) + print("Retrieving file " + staged_file.cid + "...") file_bytes = c.data.get(staged_file.cid, user.token) # Write to a file on disk - print("Saving as 'testfile_copy.txt'") with open(path.parent / "testfile_copy.txt", "wb") as f: f.write(file_bytes) + print("Saved as 'testfile_copy.txt'") diff --git a/examples/store_retrieve.py b/examples/store_retrieve.py new file mode 100644 index 0000000..68fc032 --- /dev/null +++ b/examples/store_retrieve.py @@ -0,0 +1,68 @@ +import os +from pathlib import Path +from pygate_grpc.client import PowerGateClient + + +if __name__ == "__main__": + + hostName = "127.0.0.1:5002" + + # Create client + c = PowerGateClient(hostName, False) + + # Create user + user = c.admin.users.create() + print("User created:") + print(user) + + # Stage file + print("Staging 'testfile.txt' to IPFS storage...") + path = Path(os.path.abspath(__file__)) + staged_file = c.data.stage_file(path.parent / "testfile.txt", user.token) + print("IPFS CID: " + staged_file.cid) + + # Apply the default storage config to the given file + print("Applying Filecoin storage config to CID...") + job = c.config.apply(staged_file.cid, override=False, token=user.token) + + # Report back the Job ID for the successful Filecoin storage job + print("File successfully added to Filecoin storage.") + print("Job ID: " + job.jobId) + + # Override push with another config + print("Applying new config settings to file...") + addresses = c.wallet.addresses(user.token) + wallet = addresses[0].address + new_config = { + "hot": {"enabled": True, "allowUnfreeze": True, "ipfs": {"addTimeout": 30}}, + "cold": { + "enabled": True, + "filecoin": { + "replicationFactor": 1, + "dealMinDuration": 518400, + "excludedMiners": ["t01101"], + "trustedMiners": ["t01000", "t02000"], + "countryCodes": ["ca", "nl"], + "renew": {"enabled": True, "threshold": 3}, + "address": wallet, + "maxPrice": 50, + }, + }, + "repairable": True, + } + + c.config.apply(staged_file.cid, override=True, config=new_config, token=user.token) + + # Check that CID is stored + check = c.data.cid_info([staged_file.cid], user.token) + print("Checking CID storage...") + print(check) + + # Get the data back + print("Retrieving file " + staged_file.cid + "...") + file_bytes = c.data.get(staged_file.cid, user.token) + + # Write to a file on disk + with open(path.parent / "testfile_copy.txt", "wb") as f: + f.write(file_bytes) + print("Saved as 'testfile_copy.txt'") From 56d9ea05da6239002745072cc0216c47b11473f3 Mon Sep 17 00:00:00 2001 From: Peter Van Garderen Date: Fri, 27 Nov 2020 12:59:23 -0800 Subject: [PATCH 11/12] complete rename --- examples/apply_pull_file.py | 68 ------------------------------------- examples/store_retrieve.py | 2 +- 2 files changed, 1 insertion(+), 69 deletions(-) delete mode 100644 examples/apply_pull_file.py diff --git a/examples/apply_pull_file.py b/examples/apply_pull_file.py deleted file mode 100644 index 5b949d4..0000000 --- a/examples/apply_pull_file.py +++ /dev/null @@ -1,68 +0,0 @@ -import os -from pathlib import Path -from pygate_grpc.client import PowerGateClient - - -if __name__ == "__main__": - - hostName = "127.0.0.1:5002" - - # Create client - c = PowerGateClient(hostName, False) - - # Create user - user = c.admin.users.create() - print("User created:") - print(user) - - # Stage file - print("Staging testfile.txt to IPFS storage") - path = Path(os.path.abspath(__file__)) - staged_file = c.data.stage_file(path.parent / "testfile.txt", user.token) - print("IPFS CID: " + staged_file.cid) - - # Apply the default storage config to the given file - print("Applying Filecoin storage config to CID...") - job = c.config.apply(staged_file.cid, override=False, token=user.token) - - # Report back the Job ID for the successful Filecoin storage job - print("File successfully added to Filecoin storage.") - print("Job ID: " + job.jobId) - - # Override push with another config - print("Applying new config settings to file...") - addresses = c.wallet.addresses(user.token) - wallet = addresses[0].address - new_config = { - "hot": {"enabled": True, "allowUnfreeze": True, "ipfs": {"addTimeout": 30}}, - "cold": { - "enabled": True, - "filecoin": { - "replicationFactor": 1, - "dealMinDuration": 518400, - "excludedMiners": ["t01101"], - "trustedMiners": ["t01000", "t02000"], - "countryCodes": ["ca", "nl"], - "renew": {"enabled": True, "threshold": 3}, - "address": wallet, - "maxPrice": 50, - }, - }, - "repairable": True, - } - - c.config.apply(staged_file.cid, override=True, config=new_config, token=user.token) - - # Check that CID is stored - check = c.data.cid_info([staged_file.cid], user.token) - print("Checking CID storage...") - print(check) - - # Get the data back - print("Retrieving file " + staged_file.cid + "...") - file_bytes = c.data.get(staged_file.cid, user.token) - - # Write to a file on disk - with open(path.parent / "testfile_copy.txt", "wb") as f: - f.write(file_bytes) - print("Saved as 'testfile_copy.txt'") diff --git a/examples/store_retrieve.py b/examples/store_retrieve.py index 68fc032..5b949d4 100644 --- a/examples/store_retrieve.py +++ b/examples/store_retrieve.py @@ -16,7 +16,7 @@ print(user) # Stage file - print("Staging 'testfile.txt' to IPFS storage...") + print("Staging testfile.txt to IPFS storage") path = Path(os.path.abspath(__file__)) staged_file = c.data.stage_file(path.parent / "testfile.txt", user.token) print("IPFS CID: " + staged_file.cid) From 33f4954c33984229202b0bb7557cff308c819755 Mon Sep 17 00:00:00 2001 From: Peter Van Garderen Date: Fri, 27 Nov 2020 13:01:28 -0800 Subject: [PATCH 12/12] formatting --- examples/store_retrieve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/store_retrieve.py b/examples/store_retrieve.py index 5b949d4..68fc032 100644 --- a/examples/store_retrieve.py +++ b/examples/store_retrieve.py @@ -16,7 +16,7 @@ print(user) # Stage file - print("Staging testfile.txt to IPFS storage") + print("Staging 'testfile.txt' to IPFS storage...") path = Path(os.path.abspath(__file__)) staged_file = c.data.stage_file(path.parent / "testfile.txt", user.token) print("IPFS CID: " + staged_file.cid)