Skip to content

Commit

Permalink
Merge branch 'develop' into update-team-model
Browse files Browse the repository at this point in the history
  • Loading branch information
rchan26 committed Oct 24, 2023
2 parents f9ecbd1 + 1453b6d commit baf62d9
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions airsenal/scripts/airsenal_run_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,26 @@
type=float,
default=0.0,
)
@click.option(
"--max_transfers",
help="specify maximum number of transfers to be made each gameweek (defaults to 2)",
type=click.IntRange(min=0, max=2),
default=2,
)
@click.option(
"--max_hit",
help=(
"specify maximum number of points to spend on additional transfers "
"(defaults to 8)"
),
type=click.IntRange(min=0),
default=8,
)
@click.option(
"--allow_unused",
help="If set, include strategies that waste free transfers",
is_flag=True,
)
def run_pipeline(
num_thread: int,
weeks_ahead: int,
Expand All @@ -122,6 +142,9 @@ def run_pipeline(
no_current_season: bool,
team_model: str,
epsilon: int,
max_transfers: int,
max_hit: int,
allow_unused: bool,
) -> None:
"""
Run the full pipeline, from setting up the database and filling
Expand Down Expand Up @@ -193,10 +216,20 @@ def run_pipeline(
else:
click.echo("Running optimization..")
chips_played = setup_chips(
wildcard_week, free_hit_week, triple_captain_week, bench_boost_week
wildcard_week=wildcard_week,
free_hit_week=free_hit_week,
triple_captain_week=triple_captain_week,
bench_boost_week=bench_boost_week,
)
opt_ok = run_optimize_squad(
num_thread, gw_range, fpl_team_id, dbsession, chips_played
num_thread=num_thread,
gw_range=gw_range,
fpl_team_id=fpl_team_id,
dbsession=dbsession,
chips_played=chips_played,
max_transfers=max_transfers,
max_hit=max_hit,
allow_unused=allow_unused,
)
if not opt_ok:
raise RuntimeError("Problem running optimization")
Expand Down Expand Up @@ -310,6 +343,9 @@ def run_optimize_squad(
fpl_team_id: int,
dbsession: Session,
chips_played: dict,
max_transfers: int,
max_hit: int,
allow_unused: bool,
) -> bool:
"""
Build the initial squad
Expand All @@ -325,6 +361,9 @@ def run_optimize_squad(
fpl_team_id=fpl_team_id,
num_thread=num_thread,
chip_gameweeks=chips_played,
max_transfers=max_transfers,
max_total_hit=max_hit,
allow_unused_transfers=allow_unused,
)
return True

Expand Down

0 comments on commit baf62d9

Please sign in to comment.