Skip to content
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

DSS file not detected if filename string has any spaces. #94

Closed
Realife-Brahmin opened this issue Nov 2, 2023 · 4 comments
Closed

DSS file not detected if filename string has any spaces. #94

Realife-Brahmin opened this issue Nov 2, 2023 · 4 comments
Labels

Comments

@Realife-Brahmin
Copy link

Realife-Brahmin commented Nov 2, 2023

Upon trying to run the tutorial example for this package, I realized that compile $(filename) only works with filename with no spaces. Since my computer username itself has spaces in it, the original code, which uses an absolute directory, would throw up an error, saying that truncated_filename (I mean filename truncated at the first space encountered) doesn't exist. To test this, I copied the files to a local folder and was able to replicate the problem.

using OpenDSSDirect

# Store the current directory to cd to later, as I don't like the package changing my directory at the end of the run
original_directory = pwd()

foldername = joinpath(".", "OpenDSSDirect", "5wwHs", "examples", "8500-Node") # Works

# foldername = joinpath(".", "OpenDSSDirect", "5wwHs", "examples", "8500-Node with some spaces in the name") 
# I've created a duplicate of the 8500-Node folder but inserted spaces in its name # Doesn't work

filename = joinpath(foldername, "Master.dss")

dss("""
    clear
    compile $(filename)
    solve
""")

function main()
    loadnumber = Loads.First()
    kWsum = 0.0
    kvarsum = 0.0
    
    while loadnumber > 0
        kWsum += Loads.kW()
        kvarsum += Loads.kvar()
        loadnumber = Loads.Next()
    end

    kWsum, kvarsum
end

result = main()

# Reset the working directory to its original state
cd(original_directory)

println(result)
@kdheepak
Copy link
Member

kdheepak commented Nov 2, 2023

I haven't tested this but the first thing I would try is putting quotes around the filename, i.e.

dss("""
    clear
    compile "$(filename)"
    solve
""")

OR

dss("""
    clear
    compile '$(filename)'
    solve
""")

Can you also post your operating system / version of OpenDSSDirect etc?

@PMeira PMeira added the docs label Nov 2, 2023
@PMeira PMeira closed this as completed in 3bb1328 Nov 2, 2023
@PMeira
Copy link
Member

PMeira commented Nov 2, 2023

Yep, just missing quotes as @kdheepak pointed. Thanks for reporting, @Realife-Brahmin. Although we don't plan to cover basic OpenDSS details in the docs, the examples should avoid this kind of issue and should reflect best practices. I think I updated most of the compile/redirect commands in the examples and tests, but if you find any remaining issue with those, feel free to report.

The dev docs already reflect the changes: https://dss-extensions.org/OpenDSSDirect.jl/dev/#Example

We should have a new release here in a few days, by the way.

@Realife-Brahmin
Copy link
Author

Using double quotes works for me. Thank you @kdheepak for the tip and @PMeira for the explanation and updating the doc. From my other issue, the redirect command did help me retain my working directory (and something as a beginner I'd like the example code snippet to have), but I guess you must have good reasons for not updating that.

@PMeira
Copy link
Member

PMeira commented Nov 2, 2023

but I guess you must have good reasons for not updating that

@Realife-Brahmin The redirect vs compile issue is a more general aspect with how OpenDSS itself works, so sooner or later users would find the issue anyway as various examples in the wild use compile.

Note that OpenDSS and the way the API is organized is unusual (especially the "active..." concept), so you might find some other surprises. We have some goals for a future alternative, but it will take some time to reach those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants