Skip to content

Commit 9088490

Browse files
Merge pull request #18 from CarloLucibello/cl/pil
fix for PIL imports + fix DatasetDict julia format
2 parents 10e307a + 204da15 commit 9088490

File tree

10 files changed

+19
-14
lines changed

10 files changed

+19
-14
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
version:
21-
- '1.7'
22-
- '1'
21+
- '1.9'
22+
# - '1' # add back when 1.10 is out
2323
- 'nightly'
2424
os:
2525
- ubuntu-latest

.github/workflows/TagBot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
token: ${{ secrets.GITHUB_TOKEN }}
3131
# Edit the following line to reflect the actual name of the GitHub Secret containing your private key
3232
ssh: ${{ secrets.DOCUMENTER_KEY }}
33-
# ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }}
33+
# ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }}

CondaPkg.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
channels = ["conda-forge"]
22

33
[deps]
4-
h5py = ""
5-
pillow = ">=9.1, <10"
4+
# h5py = ""
5+
# pillow = ">=9.1, <10"
6+
# pyarrow = "==6.0.0"
7+
datasets = ">=2.12, <3"
68
numpy = ">=1.20, <2"
7-
datasets = ">=2.7, <3"
8-
pyarrow = "==6.0.0"
9+
pillow = ""
10+

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "HuggingFaceDatasets"
22
uuid = "d94b9a45-fdf5-4270-b024-5cbb9ef7117d"
33
authors = ["Carlo Lucibello"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
@@ -16,7 +16,7 @@ DLPack = "0.1"
1616
ImageCore = "0.9"
1717
MLUtils = "0.4.1"
1818
PythonCall = "0.9"
19-
julia = "1.7"
19+
julia = "1.9"
2020

2121
[extras]
2222
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/HuggingFaceDatasets.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ function __init__()
4141
# https://cjdoris.github.io/PythonCall.jl/dev/pythoncall-reference/#PythonCall.pycopy!
4242
PythonCall.pycopy!(datasets, pyimport("datasets"))
4343
PythonCall.pycopy!(PIL, pyimport("PIL"))
44+
pyimport("PIL.PngImagePlugin")
45+
pyimport("PIL.JpegImagePlugin")
4446
PythonCall.pycopy!(np, pyimport("numpy"))
4547
PythonCall.pycopy!(copy, pyimport("copy"))
4648
end

src/dataset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ version of [`with_format`](@ref).
107107
"""
108108
function set_format!(ds::Dataset, format)
109109
if format == "julia"
110-
# ds.pyds.set_format("numpy")
110+
ds.pyds.reset_format() # or d.pyd.set_format("python")
111111
ds.jltransform = py2jl
112112
else
113113
ds.pyds.set_format(format)

src/datasetdict.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ version of [`with_format`](@ref).
102102
"""
103103
function set_format!(d::DatasetDict, format)
104104
if format == "julia"
105-
d.pyd.set_format("numpy")
105+
d.pyd.reset_format()
106106
d.jltransform = py2jl
107107
else
108108
d.pyd.set_format(format)

src/transforms.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function _pyconvert(x::Py)
2121
end
2222
end
2323

24+
# Do nothing on a non-Py object.
2425
_pyconvert(x) = x
2526

2627
"""
@@ -30,6 +31,7 @@ Convert Python types to Julia types applying `pyconvert` recursively.
3031
"""
3132
py2jl
3233

34+
# py2jl recurses through pycanonicalize and converts through _pyconvert
3335
py2jl(x) = pycanonicalize(_pyconvert(x))
3436

3537
pycanonicalize(x) = x

test/dataset.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ end
7474
@test x isa Dict
7575
@test x["label"] == -1
7676
@test x["idx"] == 0
77-
@show x["premise"] |> typeof
7877
@test x["premise"] isa AbstractString
7978
@test x["premise"] == "The cat sat on the mat."
8079
@test x["hypothesis"] isa AbstractString

test/datasetdict.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ end
1919
@testset "with_format(julia)" begin
2020
d = with_format(mnist, "julia")
2121
ds = d["test"]
22-
@test ds.format["type"] == "numpy"
22+
@test ds.format["type"] == nothing
2323
x = ds[1]
2424
@test x isa Dict
2525
@test x["label"] isa Int
2626
@test x["label"] == 7
27-
@test x["image"] isa Matrix{UInt8}
27+
@test x["image"] isa AbstractMatrix{<:Gray}
2828
@test size(x["image"]) == (28, 28)
2929
end
3030

0 commit comments

Comments
 (0)