Exemplo n.º 1
0
    def handle(self, *args, **options):

        network = options['network']
        clr_pk = options['clr_pk']

        if clr_pk == "all":
            active_clr_rounds = GrantCLR.objects.filter(is_active=True)
        else:
            active_clr_rounds = GrantCLR.objects.filter(pk=clr_pk)

        if active_clr_rounds:
            for clr_round in active_clr_rounds:
                print(f"CALCULATING CLR estimates for ROUND: {clr_round.round_num}")
                predict_clr(
                    save_to_db=True,
                    from_date=timezone.now(),
                    clr_round=clr_round,
                    network=network
                )
                print(f"finished CLR estimates for {clr_round.round_num}")

                # TOTAL GRANT
                # grants = Grant.objects.filter(network=network, hidden=False, active=True, link_to_new_grant=None)
                # grants = grants.filter(**clr_round.grant_filters)

                # total_clr_distributed = 0
                # for grant in grants:
                #     total_clr_distributed += grant.clr_prediction_curve[0][1]

                # print(f'Total CLR allocated for {clr_round.round_num} - {total_clr_distributed}')

        else:
            print("No active CLRs found")
Exemplo n.º 2
0
    def handle(self, *args, **options):

        network = options['network']
        clr_pk = options['clr_pk']
        what = options['what']
        sync = options['sync']
        print(network, clr_pk, what, sync)

        if clr_pk and clr_pk.isdigit():
            active_clr_rounds = GrantCLR.objects.filter(pk=clr_pk)
        else:
            active_clr_rounds = GrantCLR.objects.filter(is_active=True)

        if active_clr_rounds:
            for clr_round in active_clr_rounds:
                if sync == 'true':
                    # run it sync -> useful for payout / debugging
                    predict_clr(
                        save_to_db=True,
                        from_date=timezone.now(),
                        clr_round=clr_round,
                        network=network,
                        what=what,
                    )
                else:
                    # runs it as celery task.
                    process_predict_clr(
                        save_to_db=True,
                        from_date=timezone.now(),
                        clr_round=clr_round,
                        network=network,
                        what=what,
                    )
        else:
            print("No active CLRs found")
Exemplo n.º 3
0
    def handle(self, *args, **options):
        clr_type = options['clr_type']
        network = options['network']

        predict_clr(save_to_db=True,
                    from_date=timezone.now(),
                    clr_type=clr_type,
                    network=network)

        print("finished CLR estimates")
Exemplo n.º 4
0
Arquivo: tasks.py Projeto: srdkrt/web
def recalc_clr(self, grant_id, retry: bool = True) -> None:
    obj = Grant.objects.get(pk=grant_id)
    from grants.clr import predict_clr
    from django.utils import timezone
    for clr_round in obj.in_active_clrs.all():
        network = 'mainnet'
        predict_clr(save_to_db=True,
                    from_date=timezone.now(),
                    clr_round=clr_round,
                    network=network,
                    only_grant_pk=obj.pk)
Exemplo n.º 5
0
def process_predict_clr(self, save_to_db, from_date, clr_round,
                        network) -> None:
    from grants.clr import predict_clr

    print(
        f"CALCULATING CLR estimates for ROUND: {clr_round.round_num} {clr_round.sub_round_slug}"
    )

    predict_clr(save_to_db, from_date, clr_round, network)

    print(
        f"finished CLR estimates for {clr_round.round_num} {clr_round.sub_round_slug}"
    )
Exemplo n.º 6
0
    def handle(self, *args, **options):
        clr_type = options['clr_type']
        network = options['network']

        clr_prediction_curves = predict_clr(save_to_db=True,
                                            from_date=timezone.now(),
                                            clr_type=clr_type,
                                            network=network)

        # Uncomment these for debugging and sanity checking
        # for grant in clr_prediction_curves:
        #print("CLR predictions for grant {}".format(grant['grant']))
        #print("All grants: {}".clr_typeformat(grant['grants_clr']))
        #print("prediction curve: {}\n\n".format(grant['clr_prediction_curve']))

        # sanity check: sum all the estimated clr distributions - should be close to CLR_DISTRIBUTION_AMOUNT
        clr_data = [g['grants_clr'] for g in clr_prediction_curves]

        # print(clr_data)
        if clr_data and clr_data[0]:
            total_clr_funds = sum(
                [each_grant['clr_amount'] for each_grant in clr_data[0]])
            print("allocated CLR funds:{}".format(total_clr_funds))

        print("finished CLR estimates")
Exemplo n.º 7
0
    def handle(self, *args, **options):
        if not clr_active and not options['force']:
            print(
                'CLR round is not active according to grants.views.clr_active, so cowardly refusing to spend the CPU cycles + exiting instead'
            )
            return

        clr_type = options['clr_type']
        network = options['network']
        # identity mechanism is profiles for traditional rounds. for experimental rounds, where we saw collusion
        # make the identity mechanism into funds originated addr
        # this is a stopgap until a "one identity mechanism to rule them all is round", probably in round 6.

        predict_clr(save_to_db=True,
                    from_date=timezone.now(),
                    clr_type=clr_type,
                    network=network)

        print("finished CLR estimates")
Exemplo n.º 8
0
    def handle(self, *args, **options):
        clr_prediction_curves = predict_clr(random_data=False, save_to_db=True)

        # Uncomment these for debugging and sanity checking
        # for grant in clr_prediction_curves:
            #print("CLR predictions for grant {}".format(grant['grant']))
            #print("All grants: {}".format(grant['grants_clr']))
            #print("prediction curve: {}\n\n".format(grant['clr_prediction_curve']))

        # sanity check: sum all the estimated clr distributions - should be close to CLR_DISTRIBUTION_AMOUNT
        clr_data = [g['grants_clr'] for g in clr_prediction_curves]

        # print(clr_data)

        total_clr_funds = sum([each_grant['clr_amount'] for each_grant in clr_data[0]])
        print("allocated CLR funds:{}".format(total_clr_funds))

        print("finished CLR estimates")