Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit 16c28a5

Browse files
committed
revert workflopw
1 parent f4669fa commit 16c28a5

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ on: ["push"]
44

55
jobs:
66
test:
7-
runs-on: public.ecr.aws/modular/max-serving-de
7+
runs-on: ubuntu-latest
88
environment: basic
99
steps:
1010
- name: Check out repository code
1111
uses: actions/checkout@v2
1212
- name: Install dependencies
1313
run: |
14-
# curl https://get.modular.com | MODULAR_AUTH=${{ secrets.MODULAR_AUTH }} sh -
15-
# modular auth ${{ secrets.MODULAR_AUTH }}
16-
# # modular install --install-version 24.1.0 mojo
17-
# # TODO: fix version pinning of mojo https://github.com/modularml/mojo/issues/1887
18-
# modular install mojo
14+
curl https://get.modular.com | MODULAR_AUTH=${{ secrets.MODULAR_AUTH }} sh -
15+
modular auth ${{ secrets.MODULAR_AUTH }}
16+
# modular install --install-version 24.1.0 mojo
17+
# TODO: fix version pinning of mojo https://github.com/modularml/mojo/issues/1887
18+
modular install mojo
1919
pip install pytest
2020
pip install git+https://github.com/guidorice/mojo-pytest.git
2121
- name: Unit Tests
2222
run: |
23-
# export MODULAR_HOME="/home/runner/.modular"
24-
# export PATH="/home/runner/.modular/pkg/packages.modular.com_mojo/bin:$PATH"
23+
export MODULAR_HOME="/home/runner/.modular"
24+
export PATH="/home/runner/.modular/pkg/packages.modular.com_mojo/bin:$PATH"
2525
pytest

gojo/builtins/_bytes.mojo

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ struct Bytes(Stringable, Sized, CollectionElement):
4343
"""Returns the position of the last byte written to Bytes since it is 0 initialized."""
4444
return self.write_position
4545

46+
fn resize(inout self, new_size: Int):
47+
"""Resizes the Bytes to the new size. If the new size is larger than the current size, the new bytes are 0 initialized."""
48+
self._vector.resize(new_size, 0)
49+
50+
# If the internal vector was resized to a smaller size than what was already written, the write position should be moved back.
51+
if new_size < self.write_position:
52+
self.write_position = new_size
53+
54+
fn available(self) -> Int:
55+
return len(self._vector) - self.write_position - 1
56+
4657
fn __len__(self) -> Int:
4758
return len(self._vector)
4859

gojo/io/file.mojo

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ struct FileWrapper(io.ReadWriteSeeker, io.ByteReader):
4242
var elements_copied = copy(dest, Bytes(result))
4343
dest = dest[:elements_copied]
4444
return elements_copied
45+
46+
fn read_all(inout self) raises -> Bytes:
47+
var result = Bytes(4096)
48+
while True:
49+
try:
50+
var temp = Bytes(4096)
51+
_ = self.read(temp, 4096)
52+
53+
# If new bytes will overflow the result, resize it.
54+
if result.size() + temp.size() > len(result):
55+
result.resize(len(result) * 2)
56+
result += temp
57+
58+
if temp.size() < 4096:
59+
raise Error(io.EOF)
60+
except e:
61+
if str(e) == "EOF":
62+
break
63+
raise
64+
return result
4565

4666
fn read_byte(inout self) raises -> Byte:
4767
return self.read_bytes(1)[0]

0 commit comments

Comments
 (0)