Skip to content

Commit

Permalink
[client] add batch size to python part
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb committed Jan 17, 2025
1 parent b5e4574 commit 5f5ceb2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ jobs:
fail-fast: false
matrix:
test:
- bootstrap_demo_community.py --signer //Bob --test
- bot-community-test -f http://host.docker.internal:5000/api
- bootstrap_demo_community.py --signer //Bob --call-wrapping sudo --test
- bot-community-test -f --call-wrapping sudo http://host.docker.internal:5000/api
# Todo: #386
# - test-register-businesses -f http://host.docker.internal:5000/api
steps:
Expand Down
9 changes: 5 additions & 4 deletions client/bootstrap_demo_community.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def update_spec_with_cid(file, cid):
spec_json.truncate()


def create_community(client, spec_file_path, ipfs_local, signer, wrap_call="none"):
def create_community(client, spec_file_path, ipfs_local, signer, wrap_call="none", batch_size=100):
# non sudoer can create community on gesell (provide --signer but don't use //Alice), but not on parachain (where council will create)
cid = client.new_community(spec_file_path, signer=signer, wrap_call=wrap_call)
cid = client.new_community(spec_file_path, signer=signer, wrap_call=wrap_call, batch_size=batch_size)
if len(cid) > 10:
print(f'👬 Registered community with cid: {cid}')
else:
Expand Down Expand Up @@ -412,9 +412,10 @@ def test_democracy(client, cid):
help='Specify community spec-file to be registered.')
@click.option('-t', '--test', is_flag=True, help='if set, run integration tests.')
@click.option('-w', '--wrap-call', default="none", help='wrap the call, values: none|sudo|collective')
def main(ipfs_local, client, signer, url, port, spec_file, test, wrap_call):
@click.option('-b', '--batch-size', default=100, help='batch size of the addLocation call (parachain is limited to 15)')
def main(ipfs_local, client, signer, url, port, spec_file, test, wrap_call, batch_size):
client = Client(rust_client=client, node_url=url, port=port)
cid = create_community(client, spec_file, ipfs_local, signer, wrap_call=wrap_call)
cid = create_community(client, spec_file, ipfs_local, signer, wrap_call=wrap_call, batch_size=batch_size)

newbie = client.create_accounts(1)[0]
faucet(client, cid, [account3, newbie])
Expand Down
7 changes: 5 additions & 2 deletions client/bot-community.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
@click.option('-f', '--faucet_url', default='http://localhost:5000/api',
help='url for the faucet (only needed for test/benchmark cmd)')
@click.option('-w', '--wrap-call', default="none", help='wrap the call, values: none|sudo|collective')
@click.option('-b', '--batch-size', default=100, help='batch size of the addLocation call (parachain is limited to 15)')
@click.pass_context
def cli(ctx, client, port, ipfs_local, url, faucet_url, wrap_call):
def cli(ctx, client, port, ipfs_local, url, faucet_url, wrap_call, batch_size):
ctx.ensure_object(dict)
cl = set_local_or_remote_chain(client, port, url)
ctx.obj['client'] = cl
Expand All @@ -66,6 +67,7 @@ def cli(ctx, client, port, ipfs_local, url, faucet_url, wrap_call):
ctx.obj['url'] = url
ctx.obj['faucet_url'] = faucet_url
ctx.obj['wrap_call'] = wrap_call
ctx.obj['batch_size'] = batch_size


@cli.command()
Expand All @@ -74,6 +76,7 @@ def init(ctx):
client = ctx['client']
faucet_url = ctx['faucet_url']
wrap_call = ctx['wrap_call']
batch_size = ctx['batch_size']
purge_keystore_prompt()

root_dir = os.path.realpath(ASSETS_PATH)
Expand All @@ -95,7 +98,7 @@ def init(ctx):
print(f"waiting for ceremony phase Registering. now is {phase}")
client.await_block()

cid = client.new_community(specfile, signer='//Alice', wrap_call=wrap_call)
cid = client.new_community(specfile, signer='//Alice', wrap_call=wrap_call, batch_size=batch_size)
print(f'created community with cid: {cid}')
write_cid(cid)
client.await_block()
Expand Down
4 changes: 2 additions & 2 deletions client/py_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ def reputation(self, account):
(cindex, cid, rep.strip().split('::')[1]))
return reputation_history

def new_community(self, specfile, signer=None, wrap_call="none", pay_fees_in_cc=False):
def new_community(self, specfile, signer=None, wrap_call="none", batch_size=100, pay_fees_in_cc=False):
cmd = ["new-community", specfile]
if signer:
cmd += ["--signer", signer]

cmd += ["--wrap-call", wrap_call]
cmd += ["--wrap-call", wrap_call, "--batch-size", str(batch_size)]
ret = self.run_cli_command(cmd, pay_fees_in_cc=pay_fees_in_cc)
ensure_clean_exit(ret)
return ret.stdout.decode("utf-8").strip()
Expand Down

0 comments on commit 5f5ceb2

Please sign in to comment.