-
Notifications
You must be signed in to change notification settings - Fork 0
CI-CD Tests, General PR #23
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
base: main
Are you sure you want to change the base?
Changes from all commits
7ec2479
01f5efa
39a36c0
f6c79ab
e4bed2a
9be62c5
9f11f72
dbe8754
58f4ad9
9aa58e6
4cad456
65d12cc
ccd048c
bd735b9
74b8477
c818fa4
0795a07
2eb4fb2
6d46768
fd70c6f
3eb36c3
c1d2e34
b0437d6
3260ceb
ac05e3f
0a43a51
5c72984
d7368f2
f9d6fce
a8a0fa7
95b8d70
7fce7d7
fcd05c0
fb63b9f
e9bc3f0
1b0204f
64f3f20
06e9145
e212c37
6bbe83e
7413938
ea0a7c8
d813b9e
7f770fb
9fb3333
cb3b562
870b73d
ce3894f
635c143
30c66e6
57ab303
9eb2ffd
674d4c8
b93b4c5
c2c5bd6
eaef18f
5d065e5
3b6f41f
d2cef1b
29d403c
c9b2f8a
53fb182
ff4630f
cd2a099
0cc61c9
976e2d5
4e454ad
b3f5cbb
02e25ef
ff205e1
0050142
27a1df6
8cf8d54
ee20f11
fc76fd9
8ec3094
ad1c4bd
e3031fc
da334a7
a7efcc4
3d2ff40
e48e5a8
1c5ba92
a6988c1
bd370b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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.") | ||
| 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) |
| 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() |
| 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) |
| 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." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from causalbench.modules.task import Task | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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." | ||
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need comments on why we do these. |
||
| pip install torch | ||
|
|
||
| pip install build | ||
| python -m build | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prat-man @AbhinavGor