-
Notifications
You must be signed in to change notification settings - Fork 21
Merge to main #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge to main #141
Changes from all commits
9072c90
967093a
68aa05b
1eeb423
b4c5fbf
fe6e866
b2d1466
1c20c5e
4c7cdfa
4086a54
b55ba2c
230f89a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -51,6 +51,9 @@ class Dataset(TorchDataset): | |||||
| """ | ||||||
|
|
||||||
| def __init__(self, dataset_meta: DatasetMeta, **kwargs): | ||||||
| trust_remote_code = bool(os.environ.get('TWINKLE_TRUST_REMOTE_CODE', '1')) | ||||||
| if not trust_remote_code: | ||||||
| kwargs['trust_remote_code'] = False | ||||||
| dataset = self._load_dataset(dataset_meta, **kwargs) | ||||||
| self.datasets = {dataset_meta.get_id(): dataset} | ||||||
| self.dataset = dataset | ||||||
|
|
@@ -247,6 +250,9 @@ def add_dataset(self, dataset_meta: DatasetMeta, **kwargs): | |||||
| Args: | ||||||
| dataset_meta: The dataset_meta information of the loaded dataset. | ||||||
| """ | ||||||
| trust_remote_code = bool(os.environ.get('TWINKLE_TRUST_REMOTE_CODE', '1')) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same issues as in the constructor: the
Suggested change
|
||||||
| if not trust_remote_code: | ||||||
| kwargs['trust_remote_code'] = False | ||||||
| dataset = self._load_dataset(dataset_meta, **kwargs) | ||||||
| self.datasets[dataset_meta.get_id()] = dataset | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -97,7 +97,8 @@ def to_tensor(_input): | |||||||||
| # so tensor ops like labels != ignore_index or .to(device) would fail without this. | ||||||||||
| if isinstance(value, np.ndarray): | ||||||||||
| value = torch.from_numpy(value) | ||||||||||
| elif isinstance(value, list) and isinstance(value[0], (int, float, np.number)): | ||||||||||
| elif (isinstance(value, list) and isinstance(value[0], | ||||||||||
| (int, float, np.number))) or key == 'position_ids': | ||||||||||
|
Comment on lines
+100
to
+101
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing
Suggested change
|
||||||||||
| value = torch.tensor(value) | ||||||||||
| elif key in self.VLM_CONCAT_FIELDS: | ||||||||||
| if not isinstance(value[0], torch.Tensor): | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two issues with this line:
bool()on any non-empty string returnsTrue. Sinceos.environ.getreturns a string,bool("0")will beTrue, meaning the environment variable cannot be used to settrust_remote_codetoFalseas intended.osmodule is not imported in this file (onlyos.pathis), so accessingos.environwill raise aNameErrorat runtime.