-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from macrocosm-os/dev
Release 1.0.1
- Loading branch information
Showing
14 changed files
with
236 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
from typing import Optional | ||
from typing import List, Optional | ||
|
||
import constants | ||
from competitions.data import Competition, CompetitionId | ||
from competitions.data import Competition, CompetitionId, ModelConstraints | ||
|
||
|
||
def get_competition(id: CompetitionId) -> Optional[Competition]: | ||
"""Returns the competition with the given id, or None if it does not exist.""" | ||
for x in constants.COMPETITION_SCHEDULE: | ||
if x.id == id: | ||
return x | ||
def get_model_constraints(id: CompetitionId) -> Optional[ModelConstraints]: | ||
"""Returns the model constraints for the given id, or None if it does not exist.""" | ||
return constants.MODEL_CONSTRAINTS_BY_COMPETITION_ID.get(id, None) | ||
|
||
|
||
def get_competition_for_block(id: CompetitionId, block: int) -> Optional[Competition]: | ||
"""Returns the competition for the given id at the given block, or None if it does not exist.""" | ||
competition_schedule = get_competition_schedule_for_block(block) | ||
for comp in competition_schedule: | ||
if comp.id == id: | ||
return comp | ||
return None | ||
|
||
|
||
def get_competition_schedule_for_block(block: int) -> List[Competition]: | ||
"""Returns the competition schedule at block.""" | ||
competition_schedule = None | ||
for b, schedule in constants.COMPETITION_SCHEDULE_BY_BLOCK: | ||
if block >= b: | ||
competition_schedule = schedule | ||
assert ( | ||
competition_schedule is not None | ||
), f"No competition schedule found for block {block}" | ||
return competition_schedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
from transformers import AutoTokenizer, PreTrainedTokenizer | ||
|
||
from competitions.data import Competition | ||
from competitions.data import ModelConstraints | ||
|
||
|
||
def load_tokenizer( | ||
competition: Competition, cache_dir: str = None | ||
model_constraints: ModelConstraints, cache_dir: str = None | ||
) -> PreTrainedTokenizer: | ||
"""Returns the fixed tokenizer for the given competition.""" | ||
"""Returns the fixed tokenizer for the given model constraints.""" | ||
return AutoTokenizer.from_pretrained( | ||
competition.constraints.tokenizer, cache_dir=cache_dir | ||
model_constraints.tokenizer, cache_dir=cache_dir | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.