Skip to content

Conversation

christopher-wild
Copy link
Contributor

I think a discussion around the usability of https://github.com/CITCOM-project/CausalTestingFramework/blob/json_poisson_example/json_frontend/examples/poisson/causal_test_setup.py would be useful.

Currently the frontend assumes you correctly structure the custom user python code as per the example which isn't ideal. The obvious alternative to me is having a class that can be extended, maybe even an abstract one with properties to enforce it is done correctly. However if we want the framework to be as open as possible to people without python background classes and class extensions might just be another barrier to using it?

Not sure if this is best discussed in a comment or two or with a meeting :)

@jmafoster1
Copy link
Contributor

Personally, I quite like a class extension, but it is potentially a "barrier to entry". Having said that, if someone can write a complex computational model which requires our testing framework in order to test it effectively, they should be able to manage extending a class...

@christopher-wild
Copy link
Contributor Author

That is probably very true, if they can jump every barrier up to the point of using the framework, one class extension hopefully won't stop them!

I'll create the class extension and then if needed, we can always discuss again when it's in front of us

@codecov
Copy link

codecov bot commented May 18, 2022

Codecov Report

Merging #67 (e29ebf0) into main (8637a88) will decrease coverage by 9.97%.
The diff coverage is 1.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
- Coverage   86.95%   76.98%   -9.98%     
==========================================
  Files          12       13       +1     
  Lines         820      934     +114     
==========================================
+ Hits          713      719       +6     
- Misses        107      215     +108     
Impacted Files Coverage Δ
causal_testing/json_front/json_class.py 0.00% <0.00%> (ø)
causal_testing/testing/causal_test_outcome.py 76.38% <ø> (+3.25%) ⬆️
causal_testing/data_collection/data_collector.py 84.37% <100.00%> (ø)
causal_testing/testing/intervention.py 0.00% <0.00%> (-100.00%) ⬇️
causal_testing/testing/causal_test_case.py 100.00% <0.00%> (ø)
causal_testing/specification/causal_dag.py 98.61% <0.00%> (+0.21%) ⬆️
causal_testing/testing/causal_test_engine.py 91.42% <0.00%> (+0.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 683e6c5...e29ebf0. Read the comment docs.

@bobturneruk bobturneruk marked this pull request as ready for review May 25, 2022 12:15
@bobturneruk
Copy link
Contributor

How would it be if https://github.com/CITCOM-project/CausalTestingFramework/blob/json_poisson_example/json_frontend/process_causal_tests_json.py were moved into causal_testing/, https://github.com/CITCOM-project/CausalTestingFramework/tree/json_poisson_example/json_frontend/examples/poisson moved into examples/ and the readmes merged? Would this better present the "JSON Frontend" as part of causal testing framework? cc @jmafoster1 @cwild-UoS @AndrewC19

@jmafoster1
Copy link
Contributor

Go ahead. I have no strong opinions...

@christopher-wild
Copy link
Contributor Author

How would it be if https://github.com/CITCOM-project/CausalTestingFramework/blob/json_poisson_example/json_frontend/process_causal_tests_json.py were moved into causal_testing/, https://github.com/CITCOM-project/CausalTestingFramework/tree/json_poisson_example/json_frontend/examples/poisson moved into examples/ and the readmes merged? Would this better present the "JSON Frontend" as part of causal testing framework? cc @jmafoster1 @cwild-UoS @AndrewC19

Sounds good to me @bobturneruk, it could be overlooked in its current structure

Copy link
Contributor

@bobturneruk bobturneruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It would be great to see json_frontend/process_causal_tests_json.py brought into the package and the example moved into the folder with the other examples. Please ignore the codacy notes. I think codecov and github are having some interaction problems. Tests for json_frontend/process_causal_tests_json.py should be added later.

@jmafoster1
Copy link
Contributor

When I run it, I'm getting a bunch of errors of the form

TypeError: 'NoneType' object is not callable
Exception ignored in: <function AstRef.__del__ at 0x7fe9e8920280>
Traceback (most recent call last):
  File "/home/michael/anaconda3/envs/causecumber/lib/python3.9/site-packages/z3/z3.py", line 351, in __del__

Not a very helpful stack trace, but please can you look into this?

@christopher-wild
Copy link
Contributor Author

Very unhelpful stack trace I agree..

I just tried again with a fresh conda environment with the latest CTF from main branch and it worked okay. When did you last update the CTF in your conda env?

@jmafoster1
Copy link
Contributor

Thursday

jmafoster1 and others added 2 commits July 14, 2022 16:24
Changed the backslashes to forward slashes in filepaths
@@ -0,0 +1,32 @@
# JSON Causal Testing Framework Frontend
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is going to be a bit tricky to find here in the package. It might be better merged with the main readme for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be a good idea to move this readme to the readthedocs and point to it from the main readme?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would also work. Examples / tutorials should be prominent.

4. Meta constraint functions
5. Mapping JSON distributions, effects, and estimators to python objects

`examples/poisson/causal_tests.json` is the JSON file that allows for the easy specification of multiple causal tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need quite a bit more instruction for anyone not already familiar with the package to use this. I suggest making an issue to keep track of this. It could be that a jupyter notebook is is a good next step.

description="A script for parsing json config files for the Causal Testing Framework")
parser.add_argument("-f", help="if included, the script will stop if a test fails",
action="store_true")
parser.add_argument("--directory_path", help="path to the json file containing the causal tests",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the default will work here, as it's supposed to be setting a folder / directory, not a specific file. And the filenames are hardcoded elsewhere (in causal_testing/json_front/json_class.py). Maybe get rid of the CLI arg and look for files in the same folder as the script for now? Or get rid of the default value? We may want to look at this again after merging, depending on expected user needs around file locations and naming. I would have thought that, at least, not everyone would want to call their data data.csv which I think is the current requirement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I think now that the door has been opened in terms of the user writing more python code, the simplest approach is expect the user to specify the paths in causal_test_setup.py. This way the file names and locations are completely flexible and up to the user

Copy link
Contributor

@bobturneruk bobturneruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good. I'd like to get a deeper understanding and maybe a simpler example / more documentation / a jupyter notebook implementation will help with this once merged. I wonder if some things might be named differently. Maybe "json interface" is better than "json frontend"? And perhaps causal_test_setup.py could be run_causal_tests.py?

Generally liking how all the example specific stuff is in examples/poisson now.

setup.py Outdated
]

setup(
name="causal_testing_framework",
version="0.0.1",
install_requires=requirements,
packages=find_packages(),
entry_points={
'console_scripts': [
'run_json = causal_testing.json_frontend:main'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, but is it used in any of the current examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this, I was using this method before we swapped the main function from being in json_class.py to causal_test_setup.py. Now that the main function is in a script that the user is free to put and call from where they want, I'm not sure if there is a way to have an entry point to the main function.

Ill remove these lines for now

@christopher-wild christopher-wild merged commit 4a6958b into main Jul 21, 2022
@christopher-wild christopher-wild deleted the json_poisson_example branch July 21, 2022 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants