Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow a server to charge for api calls #9044

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b581021
notebooks/payments/00-load-data.ipynb
petermchale May 20, 2024
9162245
Merge branch 'dev' into payments
petermchale May 21, 2024
8789c3e
Merge branch 'dev' into petermchale/payments
petermchale May 21, 2024
dd99ebe
Merge branch 'dev' into petermchale/payments
petermchale May 23, 2024
a5d7941
delete notebooks/payments/00-load-data.ipynb
petermchale Jun 5, 2024
cb73044
Merge branch 'dev' into petermchale/payments
petermchale Jun 5, 2024
f722894
incorporate 00 and 01 notebook into payments driver code
petermchale Jun 22, 2024
c348a24
set and get payment auth tokens
petermchale Jul 8, 2024
27cc81a
Merge branch 'dev' into petermchale/payments; concatenated object_ver…
petermchale Jul 9, 2024
99483ae
Merge branch 'dev' into petermchale/payments; fix merge conflicts in …
petermchale Jul 9, 2024
8d08bdc
remove trailing whitespace
petermchale Jul 9, 2024
a243d82
make tab into four spaces
petermchale Jul 9, 2024
2f2001f
update driver code to reflect new syft api
petermchale Jul 9, 2024
b2f094e
update demo notebook to reflect new syft api
petermchale Jul 9, 2024
adf4e55
initialize node with payment parameters
petermchale Jul 12, 2024
18d94fd
change example payment configuration of node
petermchale Jul 12, 2024
3f9f97b
implement an example pricing plan for node
petermchale Jul 13, 2024
dbc306c
Merge branch 'dev' into petermchale/payments; lost payment stuff in r…
petermchale Jul 13, 2024
ba29266
restore payment stuff after big rename
petermchale Jul 14, 2024
cb9bd71
replace 'node' with 'server'
petermchale Jul 14, 2024
9bd66f2
Merge branch 'dev' into petermchale/payments
petermchale Jul 14, 2024
12345be
change 'node' to 'server' in notebook
petermchale Jul 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/syft/src/syft/orchestra.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ def deploy_to_python(
background_tasks: bool = False,
debug: bool = False,
migrate: bool = False,
payment_required: bool = False,
server_payment_handle: str | None = None,
payment_api: str | None = None,
compute_price_module_path: str | None = None,
compute_price_func_name: str | None = None
) -> ServerHandle:
worker_classes = {
ServerType.DATASITE: Datasite,
Expand Down Expand Up @@ -204,6 +209,11 @@ def deploy_to_python(
"background_tasks": background_tasks,
"debug": debug,
"migrate": migrate,
"payment_required": payment_required,
"server_payment_handle": server_payment_handle,
"payment_api": payment_api,
"compute_price_module_path": compute_price_module_path,
"compute_price_func_name": compute_price_func_name
}

if port:
Expand Down Expand Up @@ -300,6 +310,11 @@ def launch(
background_tasks: bool = False,
debug: bool = False,
migrate: bool = False,
payment_required: bool = False,
server_payment_handle: str | None = None,
payment_api: str | None = None,
compute_price_module_path: str | None = None,
compute_price_func_name: str | None = None
) -> ServerHandle:
if dev_mode is True:
thread_workers = True
Expand Down Expand Up @@ -338,6 +353,11 @@ def launch(
background_tasks=background_tasks,
debug=debug,
migrate=migrate,
payment_required=payment_required,
server_payment_handle=server_payment_handle,
payment_api=payment_api,
compute_price_module_path=compute_price_module_path,
compute_price_func_name=compute_price_func_name
)
display(
SyftInfo(
Expand Down
84 changes: 42 additions & 42 deletions packages/syft/src/syft/protocol/protocol_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,23 @@
}
},
"User": {
"3": {
"version": 3,
"hash": "cdd25c47e32ac79e177bd26b8d3231847f4722247543954fc967686159ac17a2",
"4": {
"version": 4,
"hash": "524e8bc1ee0e7c1cb0a40ca458a3ab9d67ec2de6f251284c3615b9ad2fce2911",
"action": "add"
}
},
"UserUpdate": {
"3": {
"version": 3,
"hash": "01c3a470b326229bc892bea96b425c059edfde3bca57b0af83491a4fecbd0402",
"4": {
"version": 4,
"hash": "db54c3edaf8dc683851391c75331becee033956a95cb7f5263d8168352b11338",
"action": "add"
}
},
"UserCreate": {
"3": {
"version": 3,
"hash": "cb2d9872cba80c960c748b232547556fa69901c108d84ab46f177cb47f0dd3fc",
"4": {
"version": 4,
"hash": "974d7c99097da1c1714b7a2a9ccee6e7961a715bec1231884a38a3d44a58eef3",
"action": "add"
}
},
Expand All @@ -145,9 +145,9 @@
}
},
"UserView": {
"3": {
"version": 3,
"hash": "a07bebf2362391b915fb2554e61c98e35cb4f945ba8c3c3299dd059dc6f0e137",
"4": {
"version": 4,
"hash": "47e4befb08f1dac419e91573549b9e29012ae992af618ffd321176319cf1fbe8",
"action": "add"
}
},
Expand Down Expand Up @@ -777,6 +777,27 @@
"action": "add"
}
},
"SyftObjectMigrationState": {
"2": {
"version": 2,
"hash": "51f416fbce4ff408903b96aafa924fc3adde33b19172122b06acd04a1651c7ab",
"action": "add"
}
},
"StoreMetadata": {
"1": {
"version": 1,
"hash": "8de9a22a2765ef976bc161cb0704347d30350c085da8c8ffa876065cfca3e5fd",
"action": "add"
}
},
"MigrationData": {
"1": {
"version": 1,
"hash": "ae07a6345762b8ebe9d2a100776e2405fd17516c9d224913a3358c96480ba889",
"action": "add"
}
},
"OnDiskBlobDeposit": {
"2": {
"version": 2,
Expand Down Expand Up @@ -1093,10 +1114,17 @@
"action": "add"
}
},
"SyftObjectMigrationState": {
"ZMQClientConfig": {
"4": {
"version": 4,
"hash": "f54c62694a0b058ebf41d48b783b70423894a0609f50bc3d347b7b135d142674",
"action": "add"
}
},
"SQLiteStoreConfig": {
"2": {
"version": 2,
"hash": "51f416fbce4ff408903b96aafa924fc3adde33b19172122b06acd04a1651c7ab",
"hash": "b6d391bd7884886daef88b08734cf41b4d278b474c22cfc3574b9e7ec140c9e3",
"action": "add"
}
},
Expand Down Expand Up @@ -1156,40 +1184,12 @@
"action": "add"
}
},
"ZMQClientConfig": {
"4": {
"version": 4,
"hash": "f54c62694a0b058ebf41d48b783b70423894a0609f50bc3d347b7b135d142674",
"action": "add"
}
},
"SQLiteStoreConfig": {
"2": {
"version": 2,
"hash": "b6d391bd7884886daef88b08734cf41b4d278b474c22cfc3574b9e7ec140c9e3",
"action": "add"
}
},
"Plan": {
"2": {
"version": 2,
"hash": "eec308b8fd9437fc74a65f0cf70dff586130b35866d1e1512de49d45e7896981",
"action": "add"
}
},
"StoreMetadata": {
"1": {
"version": 1,
"hash": "8de9a22a2765ef976bc161cb0704347d30350c085da8c8ffa876065cfca3e5fd",
"action": "add"
}
},
"MigrationData": {
"1": {
"version": 1,
"hash": "ae07a6345762b8ebe9d2a100776e2405fd17516c9d224913a3358c96480ba889",
"action": "add"
}
}
}
}
Expand Down
54 changes: 45 additions & 9 deletions packages/syft/src/syft/server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ def run() -> ServerHandle | None:
parser.add_argument(
"--name", help="server name", type=str, default="syft-server", dest="name"
)
parser.add_argument(
"--server-type",
help="server type",
type=str,
default="python",
dest="server_type",
)
parser.add_argument(
"--host",
help="host for binding",
Expand Down Expand Up @@ -73,6 +66,41 @@ def run() -> ServerHandle | None:
default="True",
dest="tail",
)
parser.add_argument(
"--payment-required",
help="payment required",
type=str,
default="False",
dest="payment_required",
)
parser.add_argument(
"--server-payment-handle",
help="server payment handle",
type=str,
default="",
dest="server_payment_handle",
)
parser.add_argument(
"--payment-api",
help="payment api",
type=str,
default="",
dest="payment_api",
)
parser.add_argument(
"--compute-price-module-path",
help="compute price module path",
type=str,
default="",
dest="compute_price_module_path",
)
parser.add_argument(
"--compute-price-func-name",
help="compute price function name",
type=str,
default="",
dest="compute_price_func_name",
)

args = parser.parse_args()
if args.command != "launch":
Expand All @@ -82,18 +110,26 @@ def run() -> ServerHandle | None:
args.reset = str_to_bool(args.reset)
args.local_db = str_to_bool(args.local_db)
args.tail = str_to_bool(args.tail)
args.cmd = str_to_bool(args.cmd)
args.payment_required = str_to_bool(args.payment_required)
args.server_payment_handle = str(args.server_payment_handle)
args.payment_api = str(args.payment_api)
args.compute_price_module_path = str(args.compute_price_module_path)
args.compute_price_func_name = str(args.compute_price_func_name)

server = Orchestra.launch(
name=args.name,
server_type=args.server_type,
host=args.host,
port=args.port,
dev_mode=args.dev_mode,
reset=args.reset,
local_db=args.local_db,
processes=args.processes,
tail=args.tail,
payment_required=args.payment_required,
server_payment_handle=args.server_payment_handle,
payment_api=args.payment_api,
compute_price_module_path=args.compute_price_module_path,
compute_price_func_name=args.compute_price_func_name,
)
if not args.tail:
return server
Expand Down
Loading