Giter Club home page Giter Club logo

Comments (11)

nalimilan avatar nalimilan commented on June 10, 2024

Does it work if you manually assign the value "m1.jld" to outfile? Could you copy and paste the value of outfile here? The question mark at the end of "m1.jld?" could be the sign that an invalid character appears at the end of the string you read from the text file. In that case, it wouldn't be related at all to jldopen.

from jld.jl.

kaarthiksundar avatar kaarthiksundar commented on June 10, 2024

Yes, it works now. I did a Pkg.update() and it works fine now. Closing the issue.

from jld.jl.

kaarthiksundar avatar kaarthiksundar commented on June 10, 2024

Okay, I am running into the same issue again. It works when I do it manually. I use the following piece of code

outfile = chomp(thisline[2]) # thisline[2] contains "m1.jld\n"
file = "m1.jld"
@assert outfile == file
fid = jldopen(outfile, "w");
write(fid, "TotalTime", totalWorkTime);
close(fid);

The file created in the folder is "m1.jld\n". If you notice I did do a chomp and have an assert statement.

from jld.jl.

nalimilan avatar nalimilan commented on June 10, 2024

Do you get the same result if you do outfile = chomp("m1.jld\n")? And if you do open(outfile, "w") instead of jldopen?

from jld.jl.

kaarthiksundar avatar kaarthiksundar commented on June 10, 2024

I don't get any errors if I do that, but when I try to load up the data using julia it says ERROR: FileIO.File{FileIO.DataFormat{:UNKNOWN}}("m1.jld") couldn't be recognized by FileIO.

from jld.jl.

nalimilan avatar nalimilan commented on June 10, 2024

When you say "if I do that", do you mean when you do either of the changes separately? Please be very specific. (The fact that calling load doesn't work is because the file doesn't contain correct data when you don't call jldopen.)

Could you add @assert isfile(outfile) before calling jldopen? Could you also show the full backtrace of the error you showed in the description (i.e. with line numbers)?

from jld.jl.

kaarthiksundar avatar kaarthiksundar commented on June 10, 2024

I have a text file whose contents are as follows:

numMachines 1
timeSteps 720
categoryOneCount 1
categoryTwoPeriod 20
seed 2002
outfile m1.jld
END

I read out line by line and create a variable in my program: outfile = chomp(line[6][2])
Then, I run my algorithm and want to write its output to the outfile using the following code:

file = "m1.jld"
@assert outfile == file
fid = jldopen(outfile, "w");
write(fid, "TotalTime", totalWorkTime);
close(fid);

The program throws an error for the above code. It also creates a file named "m1.jld\n" in the same folder. The error is as follows:

ERROR: LoadError: SystemError: opening file m1.jld: No such file or directory
 in open at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
 in open at iostream.jl:102
 in close at /Users/kaarthik/.julia/v0.4/JLD/src/JLD.jl:136
 in include at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
 in include_from_node1 at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
 in process_options at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
 in _start at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
while loading /Users/kaarthik/Dropbox/Sandia/Code/main1.jl, in expression starting on line 347
HDF5-DIAG: Error detected in HDF5 (1.8.15-patch1) thread 0:
  #000: H5F.c line 301 in H5Fget_obj_count(): not a file id
    major: Invalid arguments to routine
    minor: Bad value
jl_uv_writecb() ERROR: bad file descriptor EBADF
jl_uv_writecb() ERROR: bad file descriptor EBADF
jl_uv_writecb() ERROR: bad file descriptor EBADF
jl_uv_writecb() ERROR: bad file descriptor EBADF
jl_uv_writecb() ERROR: bad file descriptor EBADF

To fix this I changed the text file to

numMachines 1
timeSteps 720
categoryOneCount 1
categoryTwoPeriod 20
seed 2002
outfile m1.jld

All I do is remove the END line and the line break at the end of the last line. Then the code works fine and the output of the algorithm is written to the m1.jld file. I am able to retrieve the file contents.

from jld.jl.

nalimilan avatar nalimilan commented on June 10, 2024

Thanks, details are useful.

Still, does @assert isfile(outfile) fail?

from jld.jl.

kaarthiksundar avatar kaarthiksundar commented on June 10, 2024

Sorry i missed that. Yes, @assert isfile(outfile) fails

 ERROR: LoadError: AssertionError: isfile(outfile)
 in include at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
 in include_from_node1 at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
 in process_options at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
 in _start at /Applications/Julia-0.4.2.app/Contents/Resources/julia/lib/julia/sys.dylib
while loading /Users/kaarthik/Dropbox/Sandia/Code/main1.jl, in expression starting on line 343

from jld.jl.

nalimilan avatar nalimilan commented on June 10, 2024

OK, so doesn't look like it's an issue with JLD.jl, but with Julia. To be clear, this code fails only at the last assertion, right?

outfile = chomp(thisline[2]) # thisline[2] contains "m1.jld\n"
file = "m1.jld"
@assert outfile == file
@assert isfile(file)
@assert isfile(outfile)

If so, does this one also fail?

outfile = thisline[2][1:end-1]
file = "m1.jld"
@assert outfile == file
@assert isfile(file)
@assert isfile(outfile)

from jld.jl.

simonster avatar simonster commented on June 10, 2024

Closing since this seems like it is not a JLD bug

from jld.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.