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

txt output file is not created with prefix when json-graph output enabled after 2nd time execution #78

Closed
yasu-sh opened this issue Dec 7, 2022 · 10 comments
Assignees
Labels

Comments

@yasu-sh
Copy link
Contributor

yasu-sh commented Dec 7, 2022

Hi,

I doubt if the existing json file suppreess the .txt file output when json-graph with prefix.
Could you fix this issue without workarounds? it makes better.

I guess the process is as below:

  1. determines prefix-filename
  2. checks existing json-file
  3. if exist, only creates json-file(same filename), but not creates txt-file.
  4. as a result, "prefix".txt file disappear

So far, I have used the workaround:

  1. deletes json and txt files
  2. executes causal-cmd
  3. rename json and txt with current date-time for next execution
PS > java -jar causal-cmd-1.4.1-jar-with-dependencies.jar --algorithm fges --data-type discrete --delimiter comma --score bdeu-score --json-graph --dataset asia.csv --prefix c-tetrad
PS > dir c-tetrad*
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2022/12/07     10:04           2044 c-tetrad.txt
-a----        2022/12/07     10:04          33109 c-tetrad_graph.json

PS > java -jar causal-cmd-1.4.1-jar-with-dependencies.jar --algorithm fges --data-type discrete --delimiter comma --score bdeu-score --json-graph --dataset asia.csv --prefix c-tetrad
PS > dir c-tetrad*
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2022/12/07     10:05          33123 c-tetrad_graph.json

PS > del c-tetrad*
PS > java -jar causal-cmd-1.4.1-jar-with-dependencies.jar --algorithm fges --data-type discrete --delimiter comma --score bdeu-score --json-graph --dataset asia.csv --prefix c-tetrad
PS > dir c-tetrad*
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2022/12/07     10:05           2045 c-tetrad.txt
-a----        2022/12/07     10:05          33123 c-tetrad_graph.json

asia.csv
data: asia.csv (created from bnlearn, data(asia))
causal-cmd version 1.4.1, downloaded from
https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/causal-cmd/1.4.1/

java -version
openjdk version "1.8.0_342"
OpenJDK Runtime Environment Corretto-8.342.07.3 (build 1.8.0_342-b07)
OpenJDK 64-Bit Server VM Corretto-8.342.07.3 (build 25.342-b07, mixed mode)

@kvb2univpitt
Copy link
Contributor

@yasu-sh Ah..I do see the bug! The .txt file should not be deleted on the second run. Ideally, if you run it the second time, it will overwrite the existing result files. Do you to have it keep the original result files? If so, I can append a number on the new result files.

@kvb2univpitt kvb2univpitt self-assigned this Dec 8, 2022
@yasu-sh
Copy link
Contributor Author

yasu-sh commented Dec 8, 2022

@kvb2univpitt Thanks for your quick response and checks.

Do you to have it keep the original result files?

No. I do not have to keep the original result files.
It is suitable and valid for me that the causal-cmd overwrites the result files if I specifiy the filename.
I think most of users do not want to check the appeded new numbers in filenames every time in this case.

@kvb2univpitt
Copy link
Contributor

@yasu-sh It's now fixed in the new release causal-cmd-1.4.2.

@yasu-sh
Copy link
Contributor Author

yasu-sh commented Dec 12, 2022

@kvb2univpitt What's a lovely action! I have cloned the repository and built it. it is solved.
I remembered the meaning of "prefix", out of consideration of "prefix" - "root" - "suffix" relationship.

fges_(numeric_datetime).txt - fges_(numeric_datetime)_graph.json ... "datetime" is root?
(prefix).txt - (prefix)_graph.json ...

But my intention has been already accepted. Related arguments names may be changed if developes like!

I checked the behaviors and building at:

  • IDE IntelliJ IDEA Community Edition 2022.2.1 w) Maven
  • java Amazon Corretto jdk1.8.0_352

@yasu-sh yasu-sh closed this as completed Dec 12, 2022
@kvb2univpitt
Copy link
Contributor

@yasu-sh I agree. It's a bit confusing with the --prefix flag. Initially, it was only meant for JSON graph output. But, I have extended to the text output. I should fix it so that the text output should look like this <prefix>_out.txt when ---prefix is used, otherwise <algorithm_name>_<numeric timestamp>_out.txt. Any suggestions? By the way, I really appreciate your help in posting bugs. :)

@yasu-sh
Copy link
Contributor Author

yasu-sh commented Dec 13, 2022

@kvb2univpitt <prefix>_out.txt would be reasonable for import programs to promise always latest output files. Intially users use interactive execution, then using the results from outside, for example converting to diagrams(node - edges).
I feel comfortable to name <prefix>_out.txt since PrintStream in defined in the code is subclass of OutputStream in java.io class.

@kvb2univpitt
Copy link
Contributor

@yasu-sh Sounds good. Instead of making another release, I'll just add it to the 1.4.2 release. I'll reopen this issue. You can close it once you verify that it's working.

@kvb2univpitt kvb2univpitt reopened this Dec 13, 2022
@yasu-sh
Copy link
Contributor Author

yasu-sh commented Dec 13, 2022

@kvb2univpitt I see. I'll have a look after updated code is commited. Thanks for your kindness.

@kvb2univpitt
Copy link
Contributor

@yasu-sh OK. It's fixed. I also fixed the help description for the prefix command-line option so that people know what the prefix is replacing:

Replace the default output filename prefix in the format of <algorithm>_<numeric timestamp>.

@yasu-sh
Copy link
Contributor Author

yasu-sh commented Dec 14, 2022

@kvb2univpitt It works! Thanks a lot. I confirmed as below.

  • pulled from development branch
  • Executed at IDE(IntelliJ IDEA), starts from main function at CausalCmdApplication.java
    "C:\Program Files\Amazon Corretto\jdk1.8.0_352\bin\java.exe" - with arguments
    --algorithm gfci --data-type discrete --delimiter comma --score bdeu-score --json-graph --dataset asia.csv --percentResampleSize 20 --numberResampling 5 --test g-square-test --prefix c-tetrad
PS asia> dir c-tetrad*
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2022/12/14     11:15          43347 c-tetrad_graph.json
-a----        2022/12/14     11:15           2306 c-tetrad_out.txt
  • Re-executed structure search
PS asia> dir c-tetrad*
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2022/12/14     11:16          37942 c-tetrad_graph.json
-a----        2022/12/14     11:16           2192 c-tetrad_out.txt

result
c-tetrad_graph.json.txt
c-tetrad_out.txt

@yasu-sh yasu-sh closed this as completed Dec 15, 2022
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

2 participants