Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
7ec2479
Your commit message
ertugrulcobann Aug 29, 2024
01f5efa
Branch update
ertugrulcobann Aug 29, 2024
39a36c0
Update python config
ertugrulcobann Aug 29, 2024
f6c79ab
Update python config
ertugrulcobann Aug 29, 2024
e4bed2a
Update yaml
ertugrulcobann Aug 29, 2024
9be62c5
update yaml
ertugrulcobann Aug 29, 2024
9f11f72
update yaml
ertugrulcobann Aug 29, 2024
dbe8754
Add conda
ertugrulcobann Aug 30, 2024
58f4ad9
Conda fix
ertugrulcobann Aug 30, 2024
9aa58e6
Conda fix
ertugrulcobann Aug 30, 2024
4cad456
Conda fix
ertugrulcobann Aug 30, 2024
65d12cc
Conda fix
ertugrulcobann Aug 30, 2024
ccd048c
Conda fix
ertugrulcobann Aug 30, 2024
bd735b9
Conda fix
ertugrulcobann Aug 30, 2024
74b8477
Conda fix
ertugrulcobann Aug 30, 2024
c818fa4
Conda fix
ertugrulcobann Aug 30, 2024
0795a07
Conda fix
ertugrulcobann Aug 30, 2024
2eb4fb2
Conda fix
ertugrulcobann Aug 30, 2024
6d46768
Conda fix
ertugrulcobann Aug 30, 2024
fd70c6f
Conda fix
ertugrulcobann Aug 30, 2024
3eb36c3
Conda fix
ertugrulcobann Aug 30, 2024
c1d2e34
Conda fix
ertugrulcobann Aug 30, 2024
b0437d6
Conda fix
ertugrulcobann Aug 30, 2024
3260ceb
Conda fix
ertugrulcobann Aug 30, 2024
ac05e3f
Conda fix
ertugrulcobann Aug 30, 2024
0a43a51
Conda fix
ertugrulcobann Aug 30, 2024
5c72984
Fix conda install
ertugrulcobann Sep 3, 2024
d7368f2
Fix conda install
ertugrulcobann Sep 3, 2024
f9d6fce
Fix conda install
ertugrulcobann Sep 3, 2024
a8a0fa7
Fix conda install
ertugrulcobann Sep 3, 2024
95b8d70
Fix conda install
ertugrulcobann Sep 3, 2024
7fce7d7
Fix conda install
ertugrulcobann Sep 3, 2024
fcd05c0
Fix conda install
ertugrulcobann Sep 3, 2024
fb63b9f
Fix conda install
ertugrulcobann Sep 3, 2024
e9bc3f0
Update test.sh
ertugrulcobann Sep 4, 2024
1b0204f
Update test.sh
ertugrulcobann Sep 4, 2024
64f3f20
Update test.yaml
ertugrulcobann Sep 4, 2024
06e9145
Update test.sh
ertugrulcobann Sep 4, 2024
e212c37
Update test.sh
ertugrulcobann Sep 4, 2024
6bbe83e
Update test.sh
ertugrulcobann Sep 4, 2024
7413938
Update test.sh
ertugrulcobann Sep 4, 2024
ea0a7c8
Update test.sh
ertugrulcobann Sep 4, 2024
d813b9e
Update test.sh
ertugrulcobann Sep 4, 2024
7f770fb
Update test.sh
ertugrulcobann Sep 4, 2024
9fb3333
Update test.sh
ertugrulcobann Sep 4, 2024
cb3b562
Update test.sh
ertugrulcobann Sep 4, 2024
870b73d
Update test.sh
ertugrulcobann Sep 4, 2024
ce3894f
Update test.sh
ertugrulcobann Sep 4, 2024
635c143
Update test.sh
ertugrulcobann Sep 4, 2024
30c66e6
Update test.sh
ertugrulcobann Sep 4, 2024
57ab303
Update test.sh
ertugrulcobann Sep 4, 2024
9eb2ffd
Update test.sh
ertugrulcobann Sep 4, 2024
674d4c8
Update test.sh
ertugrulcobann Sep 4, 2024
b93b4c5
Update test.sh
ertugrulcobann Sep 4, 2024
c2c5bd6
Update test.sh
kapkic Sep 5, 2024
eaef18f
Update pyproject.toml
kapkic Sep 5, 2024
5d065e5
Update test.sh
kapkic Sep 5, 2024
3b6f41f
Update test.sh
ertugrulcobann Sep 5, 2024
d2cef1b
Update test.sh
ertugrulcobann Sep 5, 2024
29d403c
Update test.sh
ertugrulcobann Sep 5, 2024
c9b2f8a
Update test.yaml
kapkic Sep 9, 2024
53fb182
Update test.yaml
kapkic Sep 9, 2024
ff4630f
Update test.yaml
kapkic Sep 9, 2024
cd2a099
Update test.yaml
kapkic Sep 9, 2024
0cc61c9
Update test.yaml
kapkic Sep 9, 2024
976e2d5
Create test.bat
ertugrulcobann Sep 9, 2024
4e454ad
Update test.yaml
ertugrulcobann Sep 9, 2024
b3f5cbb
Update test.yaml
ertugrulcobann Sep 9, 2024
02e25ef
Update test.bat
ertugrulcobann Sep 10, 2024
ff205e1
Rename test.bat to test.cmd
ertugrulcobann Sep 10, 2024
0050142
Update test.yaml
ertugrulcobann Sep 10, 2024
27a1df6
Update test.yaml
ertugrulcobann Sep 10, 2024
8cf8d54
Rename test.cmd to test.bat
ertugrulcobann Sep 10, 2024
ee20f11
Update test.bat
ertugrulcobann Sep 10, 2024
fc76fd9
Update test.bat
ertugrulcobann Sep 10, 2024
8ec3094
Test case for login
ertugrulcobann Sep 11, 2024
ad1c4bd
Test case for login
ertugrulcobann Sep 11, 2024
e3031fc
Test case for login
ertugrulcobann Sep 11, 2024
da334a7
Test case for login
ertugrulcobann Sep 11, 2024
a7efcc4
Test case for login
ertugrulcobann Sep 11, 2024
3d2ff40
Add test cases
ertugrulcobann Sep 16, 2024
e48e5a8
sh fixes
ertugrulcobann Sep 16, 2024
1c5ba92
sh fixes
ertugrulcobann Sep 16, 2024
a6988c1
sh fixes
ertugrulcobann Sep 16, 2024
bd370b2
sh fixes
ertugrulcobann Sep 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI/CD Test


# Controls when the workflow will run
on:
push:
branches:
- CI-CD-test
# Triggers the workflow on push or pull request events but only for the develop branch
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [Linux, Windows, macOS]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install dependencies
if: matrix.os != 'Windows'
run: |
cd causalbench-asu/tests/
bash -l test.sh

- name: Install dependencies for Windows
if: matrix.os == 'Windows'
run: |
cd causalbench-asu/tests/
.\test.bat
30 changes: 30 additions & 0 deletions causalbench-asu/tests/test-auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest
from causalbench.services.auth import init_auth
import jwt

def is_jwt(token):

# Split the token into parts
parts = token.split('.')

# A valid JWT should have exactly 3 parts
if len(parts) != 3:
return False

try:
header = jwt.get_unverified_header(token)

return True
except Exception as e:
print(f"Invalid JWT token: {e}")
return False




# Take some config yaml file, and copy to its location.
## can be ignored for now as ertugrul's creds are already there.
response = init_auth()

assert is_jwt(response), "Response is not in JWT format. Access token could not received"
print("Response is in JWT format and it is an access token.")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

17 changes: 17 additions & 0 deletions causalbench-asu/tests/test-data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from causalbench.modules import Dataset
import pytest
import pandas as pd

dataset_web = Dataset(module_id=2, version=1)
fetched_web = dataset_web.fetch()
data_web = Dataset(zip_file=fetched_web)
files_web = data_web.load()
assert isinstance(files_web["file1"].data, pd.DataFrame), "Dataset from causalbench could not be fetched."


dataset = Dataset(zip_file='data/abalone.zip')
files = dataset.load()
assert isinstance(files["file1"].data, pd.DataFrame), "Local data could not be extracted."


#dataset1.publish(public=False)
19 changes: 19 additions & 0 deletions causalbench-asu/tests/test-execute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from causalbench.modules import Run
from causalbench.modules.context import Context

def main():

# Select and fetch the Context
context1: Context = Context(module_id=1, version=1)

# Run selected Context
run: Run = context1.execute()

# Print Run execution results
print(run)

# Publish the Run
run.publish()

if __name__ == '__main__':
main()
10 changes: 10 additions & 0 deletions causalbench-asu/tests/test-metric.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from causalbench.modules import Metric

metric_web = Metric(module_id=1, version=1)
metric_path = metric_web.fetch()
metric_web = Metric(zip_file=metric_path)
assert metric_web.type=="metric", "Metric could not be fetched from web."

metric_local = Metric(zip_file='metric/accuracy_static.zip')
assert metric_local.type=="metric", "Metric could not be fetched from web."
#metric_local.publish(public=True)
12 changes: 12 additions & 0 deletions causalbench-asu/tests/test-model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from causalbench.modules import Model


model_web = Model(module_id=4, version=1)
model_path = model_web.fetch()
model1 = Model(zip_file=model_path)
#model1.publish(public=True)
assert model1.type=="model", "Model could not be fetched from web."

model2 = Model(zip_file='model/ges.zip')
#model2.publish(public=True)
assert model2.type=="model", "Local model could not be extracted."
5 changes: 5 additions & 0 deletions causalbench-asu/tests/test-task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from causalbench.modules.task import Task
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needs comments on what it specifically tests. A successful case? A failed case? A maliciously set case?


task: Task = Task(module_id='discovery.temporal')
task.load()
assert task.type=="task", "Task could not be fetched from web."
32 changes: 32 additions & 0 deletions causalbench-asu/tests/test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off
echo Creating conda environment...
call conda create -n causal-test python=3.10 -y
echo Conda environment is created
call conda activate causal-test
echo Conda environment is activated
cd ../..
echo Building package...

# Model dependicies are not installed automatically so needs to be installed manually until fix
pip install gcastle
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Need comments on why we do these.
we know the answer but it should be informative nevertheless to others.

pip install torch

pip install build
python -m build
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIRC this should take some arguments to provide the wheel output name.

for /f "delims=" %%f in ('dir /b /o-d dist\*.whl') do pip install dist\%%f & goto :end
:end
pip install PyJWT
pip install pytest
cd causalbench-asu\tests
echo "Test system"
python test-execute.py
echo "Test login function"
python test-auth.py
echo "Test dataset functions"
python test-data.py
echo "Test model functions"
python test-model.py
echo "Test metric functions"
python test-metric.py
echo "Test task functions"
python test-task.py
30 changes: 30 additions & 0 deletions causalbench-asu/tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
echo "Creating conda environment..."
conda create -n causal-test python=3.10 -y
echo Conda environment is created
conda activate causal-test
echo Conda environment is activated
cd ../..
echo "Building package..."

# Model dependicies are not installed automatically so needs to be installed manually until fix
pip install gcastle
pip install torch

pip install build
python -m build
pip install $(ls dist/*.whl | sort | tail -n 1)
pip install pytest
pip install PyJWT
cd causalbench-asu/tests
echo "Test system"
python test-execute.py
echo "Test login function"
python test-auth.py
echo "Test dataset functions"
python test-data.py
echo "Test model functions"
python test-model.py
echo "Test metric functions"
python test-metric.py
echo "Test task functions"
python test-task.py
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "causalbench-asu"
version = "0.1rc1"
version = "0.1rc3"
authors = [
{ name="CausalBench Team", email="support@causalbench.org"}
]
Expand All @@ -26,7 +26,6 @@ classifiers = [
]

dependencies = [
"gputil",
"requests",
"pyyaml",
"bunch_py3",
Expand All @@ -36,9 +35,8 @@ dependencies = [
"psutil",
"py-cpuinfo",
"pip-system-certs",
"pyadl",
"gcastle",
"torch~=2.3.0"
"gputil",
"pyadl"
]

[project.urls]
Expand All @@ -51,4 +49,4 @@ Issues = "https://github.com/EmitLab/CausalBench/issues"
only-include = ["causalbench-asu"]

[tool.hatch.build.targets.wheel]
packages = ["causalbench-asu/causalbench"]
packages = ["causalbench-asu/causalbench"]