Correct errors found during system migration

This commit is contained in:
Olivia Appleton 2022-10-17 21:10:04 -04:00
parent ae68283000
commit 46763bdf9d
GPG Key ID: AF65A9CA0FF7FD69
8 changed files with 434 additions and 423 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
**.pyc
env*.sh
logs/*
**.pyc

View File

@ -63,18 +63,22 @@ class Rule(ABC, Generic[T], DictDeserializable):
for r in chain(market.do_resolve_rules, market.resolve_to_rules):
id_list.append(id(r))
tag = str(id_list)
if not hasattr(self, 'tags_used'):
self.tags_used = set()
self.tags_used.add(tag)
return tag
def __del__(self) -> None:
"""Ensure that cached values are cleaned up on deletion."""
for tag in self.tags_used:
rule_value_cache.delete('value', tag=tag)
if hasattr(self, 'tags_used'):
for tag in self.tags_used:
rule_value_cache.delete('value', tag=tag)
def __getstate__(self) -> Mapping[str, Any]:
"""Remove sensitive/non-serializable state before dumping to database."""
state = self.__dict__.copy()
del state['tags_used']
if 'tags_used' in state:
del state['tags_used']
if 'logger' in state:
del state['logger']
return state

View File

@ -92,6 +92,8 @@ class Market:
self.__dict__.update(state)
self.client = get_client()
self.market = self.client.get_market_by_id(self.market.id)
if not hasattr(self, "event_emitter"):
self.event_emitter = EventEmitter()
self.event_emitter._lock = Lock()
self.__post_init__()

View File

@ -16,7 +16,7 @@ from ...rule.generic import AdditiveRule, ModulusRule, MultiplicitiveRule, Negat
from ...util import fibonacci
if TYPE_CHECKING: # pragma: no cover
from typing import Optional
from typing import Literal, Optional
from pytest_regressions.data_regression import DataRegressionFixture
@ -98,10 +98,10 @@ def test_at_time_rule_value() -> None:
def test_modulus_rule(data_regression: DataRegressionFixture, limit: int = 100) -> None:
val1: ResolveToValue[float] = ResolveToValue(1)
val2: ResolveToValue[float] = ResolveToValue(1)
val1: ResolveToValue[Literal['CANCEL'] | float] = ResolveToValue(1)
val2: ResolveToValue[Literal['CANCEL'] | float] = ResolveToValue(1)
rule = ModulusRule(val1, val2)
data: dict[tuple[int, int], AnyResolution] = {}
data: dict[tuple[int, float], AnyResolution] = {}
mkt: Market = None # type: ignore[assignment]
prev = 1
prev_desc: str = ''
@ -114,9 +114,10 @@ def test_modulus_rule(data_regression: DataRegressionFixture, limit: int = 100)
assert desc != prev_desc
assert len(desc) >= len(prev_desc)
prev_desc = desc
data[(x, prev)] = rule.value(mkt, refresh=True)
val = rule.value(mkt, refresh=True)
data[(x, prev)] = val
prev = x
data_regression.check(data)
data_regression.check({'answer': data})
def test_variadic_rule(
@ -127,7 +128,7 @@ def test_variadic_rule(
rule = VariadicRuleSubclass()
if VariadicRuleSubclass == MultiplicitiveRule:
limit //= 10
data: dict[int, int] = {}
data: dict[int, AnyResolution] = {}
mkt: Market = None # type: ignore[assignment]
prev_desc: str = ''
for idx, x in enumerate(fibonacci(start=2)):
@ -139,4 +140,4 @@ def test_variadic_rule(
assert len(desc) >= len(prev_desc)
prev_desc = desc
data[x] = rule.value(mkt, refresh=True)
data_regression.check(data)
data_regression.check({'answer': data})

View File

@ -1,300 +1,301 @@
? - 1
- 1
: 0
? - 2
- 1
: 0
? - 3
- 2
: 1
? - 5
- 3
: 2
? - 8
- 5
: 3
? - 13
- 8
: 5
? - 21
- 13
: 8
? - 34
- 21
: 13
? - 55
- 34
: 21
? - 89
- 55
: 34
? - 144
- 89
: 55
? - 233
- 144
: 89
? - 377
- 233
: 144
? - 610
- 377
: 233
? - 987
- 610
: 377
? - 1597
- 987
: 610
? - 2584
- 1597
: 987
? - 4181
- 2584
: 1597
? - 6765
- 4181
: 2584
? - 10946
- 6765
: 4181
? - 17711
- 10946
: 6765
? - 28657
- 17711
: 10946
? - 46368
- 28657
: 17711
? - 75025
- 46368
: 28657
? - 121393
- 75025
: 46368
? - 196418
- 121393
: 75025
? - 317811
- 196418
: 121393
? - 514229
- 317811
: 196418
? - 832040
- 514229
: 317811
? - 1346269
- 832040
: 514229
? - 2178309
- 1346269
: 832040
? - 3524578
- 2178309
: 1346269
? - 5702887
- 3524578
: 2178309
? - 9227465
- 5702887
: 3524578
? - 14930352
- 9227465
: 5702887
? - 24157817
- 14930352
: 9227465
? - 39088169
- 24157817
: 14930352
? - 63245986
- 39088169
: 24157817
? - 102334155
- 63245986
: 39088169
? - 165580141
- 102334155
: 63245986
? - 267914296
- 165580141
: 102334155
? - 433494437
- 267914296
: 165580141
? - 701408733
- 433494437
: 267914296
? - 1134903170
- 701408733
: 433494437
? - 1836311903
- 1134903170
: 701408733
? - 2971215073
- 1836311903
: 1134903170
? - 4807526976
- 2971215073
: 1836311903
? - 7778742049
- 4807526976
: 2971215073
? - 12586269025
- 7778742049
: 4807526976
? - 20365011074
- 12586269025
: 7778742049
? - 32951280099
- 20365011074
: 12586269025
? - 53316291173
- 32951280099
: 20365011074
? - 86267571272
- 53316291173
: 32951280099
? - 139583862445
- 86267571272
: 53316291173
? - 225851433717
- 139583862445
: 86267571272
? - 365435296162
- 225851433717
: 139583862445
? - 591286729879
- 365435296162
: 225851433717
? - 956722026041
- 591286729879
: 365435296162
? - 1548008755920
- 956722026041
: 591286729879
? - 2504730781961
- 1548008755920
: 956722026041
? - 4052739537881
- 2504730781961
: 1548008755920
? - 6557470319842
- 4052739537881
: 2504730781961
? - 10610209857723
- 6557470319842
: 4052739537881
? - 17167680177565
- 10610209857723
: 6557470319842
? - 27777890035288
- 17167680177565
: 10610209857723
? - 44945570212853
- 27777890035288
: 17167680177565
? - 72723460248141
- 44945570212853
: 27777890035288
? - 117669030460994
- 72723460248141
: 44945570212853
? - 190392490709135
- 117669030460994
: 72723460248141
? - 308061521170129
- 190392490709135
: 117669030460994
? - 498454011879264
- 308061521170129
: 190392490709135
? - 806515533049393
- 498454011879264
: 308061521170129
? - 1304969544928657
- 806515533049393
: 498454011879264
? - 2111485077978050
- 1304969544928657
: 806515533049393
? - 3416454622906707
- 2111485077978050
: 1304969544928657
? - 5527939700884757
- 3416454622906707
: 2111485077978050
? - 8944394323791464
- 5527939700884757
: 3416454622906707
? - 14472334024676221
- 8944394323791464
: 5527939700884757
? - 23416728348467685
- 14472334024676221
: 8944394323791464
? - 37889062373143906
- 23416728348467685
: 14472334024676221
? - 61305790721611591
- 37889062373143906
: 23416728348467685
? - 99194853094755497
- 61305790721611591
: 37889062373143906
? - 160500643816367088
- 99194853094755497
: 61305790721611591
? - 259695496911122585
- 160500643816367088
: 99194853094755497
? - 420196140727489673
- 259695496911122585
: 160500643816367088
? - 679891637638612258
- 420196140727489673
: 259695496911122585
? - 1100087778366101931
- 679891637638612258
: 420196140727489673
? - 1779979416004714189
- 1100087778366101931
: 679891637638612258
? - 2880067194370816120
- 1779979416004714189
: 1100087778366101931
? - 4660046610375530309
- 2880067194370816120
: 1779979416004714189
? - 7540113804746346429
- 4660046610375530309
: 2880067194370816120
? - 12200160415121876738
- 7540113804746346429
: 4660046610375530309
? - 19740274219868223167
- 12200160415121876738
: 7540113804746346429
? - 31940434634990099905
- 19740274219868223167
: 12200160415121876738
? - 51680708854858323072
- 31940434634990099905
: 19740274219868223167
? - 83621143489848422977
- 51680708854858323072
: 31940434634990099905
? - 135301852344706746049
- 83621143489848422977
: 51680708854858323072
? - 218922995834555169026
- 135301852344706746049
: 83621143489848422977
? - 354224848179261915075
- 218922995834555169026
: 135301852344706746049
? - 573147844013817084101
- 354224848179261915075
: 218922995834555169026
answer:
? - 1
- 1
: 0
? - 2
- 1
: 0
? - 3
- 2
: 1
? - 5
- 3
: 2
? - 8
- 5
: 3
? - 13
- 8
: 5
? - 21
- 13
: 8
? - 34
- 21
: 13
? - 55
- 34
: 21
? - 89
- 55
: 34
? - 144
- 89
: 55
? - 233
- 144
: 89
? - 377
- 233
: 144
? - 610
- 377
: 233
? - 987
- 610
: 377
? - 1597
- 987
: 610
? - 2584
- 1597
: 987
? - 4181
- 2584
: 1597
? - 6765
- 4181
: 2584
? - 10946
- 6765
: 4181
? - 17711
- 10946
: 6765
? - 28657
- 17711
: 10946
? - 46368
- 28657
: 17711
? - 75025
- 46368
: 28657
? - 121393
- 75025
: 46368
? - 196418
- 121393
: 75025
? - 317811
- 196418
: 121393
? - 514229
- 317811
: 196418
? - 832040
- 514229
: 317811
? - 1346269
- 832040
: 514229
? - 2178309
- 1346269
: 832040
? - 3524578
- 2178309
: 1346269
? - 5702887
- 3524578
: 2178309
? - 9227465
- 5702887
: 3524578
? - 14930352
- 9227465
: 5702887
? - 24157817
- 14930352
: 9227465
? - 39088169
- 24157817
: 14930352
? - 63245986
- 39088169
: 24157817
? - 102334155
- 63245986
: 39088169
? - 165580141
- 102334155
: 63245986
? - 267914296
- 165580141
: 102334155
? - 433494437
- 267914296
: 165580141
? - 701408733
- 433494437
: 267914296
? - 1134903170
- 701408733
: 433494437
? - 1836311903
- 1134903170
: 701408733
? - 2971215073
- 1836311903
: 1134903170
? - 4807526976
- 2971215073
: 1836311903
? - 7778742049
- 4807526976
: 2971215073
? - 12586269025
- 7778742049
: 4807526976
? - 20365011074
- 12586269025
: 7778742049
? - 32951280099
- 20365011074
: 12586269025
? - 53316291173
- 32951280099
: 20365011074
? - 86267571272
- 53316291173
: 32951280099
? - 139583862445
- 86267571272
: 53316291173
? - 225851433717
- 139583862445
: 86267571272
? - 365435296162
- 225851433717
: 139583862445
? - 591286729879
- 365435296162
: 225851433717
? - 956722026041
- 591286729879
: 365435296162
? - 1548008755920
- 956722026041
: 591286729879
? - 2504730781961
- 1548008755920
: 956722026041
? - 4052739537881
- 2504730781961
: 1548008755920
? - 6557470319842
- 4052739537881
: 2504730781961
? - 10610209857723
- 6557470319842
: 4052739537881
? - 17167680177565
- 10610209857723
: 6557470319842
? - 27777890035288
- 17167680177565
: 10610209857723
? - 44945570212853
- 27777890035288
: 17167680177565
? - 72723460248141
- 44945570212853
: 27777890035288
? - 117669030460994
- 72723460248141
: 44945570212853
? - 190392490709135
- 117669030460994
: 72723460248141
? - 308061521170129
- 190392490709135
: 117669030460994
? - 498454011879264
- 308061521170129
: 190392490709135
? - 806515533049393
- 498454011879264
: 308061521170129
? - 1304969544928657
- 806515533049393
: 498454011879264
? - 2111485077978050
- 1304969544928657
: 806515533049393
? - 3416454622906707
- 2111485077978050
: 1304969544928657
? - 5527939700884757
- 3416454622906707
: 2111485077978050
? - 8944394323791464
- 5527939700884757
: 3416454622906707
? - 14472334024676221
- 8944394323791464
: 5527939700884757
? - 23416728348467685
- 14472334024676221
: 8944394323791464
? - 37889062373143906
- 23416728348467685
: 14472334024676221
? - 61305790721611591
- 37889062373143906
: 23416728348467685
? - 99194853094755497
- 61305790721611591
: 37889062373143906
? - 160500643816367088
- 99194853094755497
: 61305790721611591
? - 259695496911122585
- 160500643816367088
: 99194853094755497
? - 420196140727489673
- 259695496911122585
: 160500643816367088
? - 679891637638612258
- 420196140727489673
: 259695496911122585
? - 1100087778366101931
- 679891637638612258
: 420196140727489673
? - 1779979416004714189
- 1100087778366101931
: 679891637638612258
? - 2880067194370816120
- 1779979416004714189
: 1100087778366101931
? - 4660046610375530309
- 2880067194370816120
: 1779979416004714189
? - 7540113804746346429
- 4660046610375530309
: 2880067194370816120
? - 12200160415121876738
- 7540113804746346429
: 4660046610375530309
? - 19740274219868223167
- 12200160415121876738
: 7540113804746346429
? - 31940434634990099905
- 19740274219868223167
: 12200160415121876738
? - 51680708854858323072
- 31940434634990099905
: 19740274219868223167
? - 83621143489848422977
- 51680708854858323072
: 31940434634990099905
? - 135301852344706746049
- 83621143489848422977
: 51680708854858323072
? - 218922995834555169026
- 135301852344706746049
: 83621143489848422977
? - 354224848179261915075
- 218922995834555169026
: 135301852344706746049
? - 573147844013817084101
- 354224848179261915075
: 218922995834555169026

View File

@ -1,100 +1,101 @@
1: 1
2: 3
3: 6
5: 11
8: 19
13: 32
21: 53
34: 87
55: 142
89: 231
144: 375
233: 608
377: 985
610: 1595
987: 2582
1597: 4179
2584: 6763
4181: 10944
6765: 17709
10946: 28655
17711: 46366
28657: 75023
46368: 121391
75025: 196416
121393: 317809
196418: 514227
317811: 832038
514229: 1346267
832040: 2178307
1346269: 3524576
2178309: 5702885
3524578: 9227463
5702887: 14930350
9227465: 24157815
14930352: 39088167
24157817: 63245984
39088169: 102334153
63245986: 165580139
102334155: 267914294
165580141: 433494435
267914296: 701408731
433494437: 1134903168
701408733: 1836311901
1134903170: 2971215071
1836311903: 4807526974
2971215073: 7778742047
4807526976: 12586269023
7778742049: 20365011072
12586269025: 32951280097
20365011074: 53316291171
32951280099: 86267571270
53316291173: 139583862443
86267571272: 225851433715
139583862445: 365435296160
225851433717: 591286729877
365435296162: 956722026039
591286729879: 1548008755918
956722026041: 2504730781959
1548008755920: 4052739537879
2504730781961: 6557470319840
4052739537881: 10610209857721
6557470319842: 17167680177563
10610209857723: 27777890035286
17167680177565: 44945570212851
27777890035288: 72723460248139
44945570212853: 117669030460992
72723460248141: 190392490709133
117669030460994: 308061521170127
190392490709135: 498454011879262
308061521170129: 806515533049391
498454011879264: 1304969544928655
806515533049393: 2111485077978048
1304969544928657: 3416454622906705
2111485077978050: 5527939700884755
3416454622906707: 8944394323791462
5527939700884757: 14472334024676219
8944394323791464: 23416728348467683
14472334024676221: 37889062373143904
23416728348467685: 61305790721611589
37889062373143906: 99194853094755495
61305790721611591: 160500643816367086
99194853094755497: 259695496911122583
160500643816367088: 420196140727489671
259695496911122585: 679891637638612256
420196140727489673: 1100087778366101929
679891637638612258: 1779979416004714187
1100087778366101931: 2880067194370816118
1779979416004714189: 4660046610375530307
2880067194370816120: 7540113804746346427
4660046610375530309: 12200160415121876736
7540113804746346429: 19740274219868223165
12200160415121876738: 31940434634990099903
19740274219868223167: 51680708854858323070
31940434634990099905: 83621143489848422975
51680708854858323072: 135301852344706746047
83621143489848422977: 218922995834555169024
135301852344706746049: 354224848179261915073
218922995834555169026: 573147844013817084099
354224848179261915075: 927372692193078999174
573147844013817084101: 1500520536206896083275
answer:
1: 1
2: 3
3: 6
5: 11
8: 19
13: 32
21: 53
34: 87
55: 142
89: 231
144: 375
233: 608
377: 985
610: 1595
987: 2582
1597: 4179
2584: 6763
4181: 10944
6765: 17709
10946: 28655
17711: 46366
28657: 75023
46368: 121391
75025: 196416
121393: 317809
196418: 514227
317811: 832038
514229: 1346267
832040: 2178307
1346269: 3524576
2178309: 5702885
3524578: 9227463
5702887: 14930350
9227465: 24157815
14930352: 39088167
24157817: 63245984
39088169: 102334153
63245986: 165580139
102334155: 267914294
165580141: 433494435
267914296: 701408731
433494437: 1134903168
701408733: 1836311901
1134903170: 2971215071
1836311903: 4807526974
2971215073: 7778742047
4807526976: 12586269023
7778742049: 20365011072
12586269025: 32951280097
20365011074: 53316291171
32951280099: 86267571270
53316291173: 139583862443
86267571272: 225851433715
139583862445: 365435296160
225851433717: 591286729877
365435296162: 956722026039
591286729879: 1548008755918
956722026041: 2504730781959
1548008755920: 4052739537879
2504730781961: 6557470319840
4052739537881: 10610209857721
6557470319842: 17167680177563
10610209857723: 27777890035286
17167680177565: 44945570212851
27777890035288: 72723460248139
44945570212853: 117669030460992
72723460248141: 190392490709133
117669030460994: 308061521170127
190392490709135: 498454011879262
308061521170129: 806515533049391
498454011879264: 1304969544928655
806515533049393: 2111485077978048
1304969544928657: 3416454622906705
2111485077978050: 5527939700884755
3416454622906707: 8944394323791462
5527939700884757: 14472334024676219
8944394323791464: 23416728348467683
14472334024676221: 37889062373143904
23416728348467685: 61305790721611589
37889062373143906: 99194853094755495
61305790721611591: 160500643816367086
99194853094755497: 259695496911122583
160500643816367088: 420196140727489671
259695496911122585: 679891637638612256
420196140727489673: 1100087778366101929
679891637638612258: 1779979416004714187
1100087778366101931: 2880067194370816118
1779979416004714189: 4660046610375530307
2880067194370816120: 7540113804746346427
4660046610375530309: 12200160415121876736
7540113804746346429: 19740274219868223165
12200160415121876738: 31940434634990099903
19740274219868223167: 51680708854858323070
31940434634990099905: 83621143489848422975
51680708854858323072: 135301852344706746047
83621143489848422977: 218922995834555169024
135301852344706746049: 354224848179261915073
218922995834555169026: 573147844013817084099
354224848179261915075: 927372692193078999174
573147844013817084101: 1500520536206896083275

View File

@ -1,10 +1,11 @@
1: 1
2: 2
3: 6
5: 30
8: 240
13: 3120
21: 65520
34: 2227680
55: 122522400
89: 10904493600
answer:
1: 1
2: 2
3: 6
5: 30
8: 240
13: 3120
21: 65520
34: 2227680
55: 122522400
89: 10904493600

View File

@ -32,12 +32,12 @@ def pr_tup(request: PytestRequest[tuple[str, str, int]]) -> tuple[str, str, int]
return request.param
@manifold_vcr.use_cassette()
@manifold_vcr.use_cassette() # type: ignore
def test_auth_login() -> None:
login()
@manifold_vcr.use_cassette()
@manifold_vcr.use_cassette() # type: ignore
def test_unauth_login() -> None:
unauth_login()