Skip to content

Commit

Permalink
Bumping version to 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Liby99 committed Jul 1, 2023
1 parent d35f3bf commit bfcad12
Show file tree
Hide file tree
Showing 368 changed files with 15,598 additions and 2,148 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/scallop-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Scallop Core

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- nightly
steps:
- uses: actions/checkout@v3
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo test --verbose --workspace --release
60 changes: 60 additions & 0 deletions .github/workflows/scallopy-torch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Scallopy with torch-tensor feature

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
SCALLOPDIR: ${{ github.workspace }}
LD_LIBRARY_PATH: "/opt/intel/oneapi/mkl/latest/lib/intel64:${{ github.env.LD_LIBRARY_PATH }}"

jobs:
build-and-test:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
rust: [nightly]
python: ["3.10"]
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}

- name: Add conda to system path
run: echo $CONDA/bin >> $GITHUB_PATH

- name: Install PyTorch
run: conda install pytorch::pytorch=2.0.0 -c pytorch

- name: Install other dependencies
run: conda install maturin tqdm

- name: Install MKL
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
sudo apt-get install -y intel-oneapi-mkl
python3 -m pip install mkl
ls /opt/intel/oneapi/mkl/latest/lib/intel64 # Investigating whether the library is successfully installed
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true

- name: Install scallopy with torch tensor features
run: make install-scallopy-torch

- name: Test
run: python3 etc/scallopy/tests/test.py
46 changes: 46 additions & 0 deletions .github/workflows/scallopy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Scallopy

on: [push]

env:
SCALLOPDIR: ${{ github.workspace }}

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Add conda to system path
run: echo $CONDA/bin >> $GITHUB_PATH

- name: Install PyTorch
run: conda install pytorch::pytorch torchvision torchaudio -c pytorch

- name: Install other dependencies
run: conda install maturin tqdm

- name: Setup rustup toolchain
run: |
rustup update nightly
rustup default nightly
- name: Install scallopy
run: make install-scallopy

- name: Test
run: python3 etc/scallopy/tests/test.py
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Rust and compilation
target
/.tmp
/Cargo.lock

# MacOS
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Ziyang Li

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 11 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# (Latest) v0.1.9, Apr 24, 2023
# (Latest) v0.2.0, Jun 11, 2023

- Fixing CSV loading and its performance; adding new modes to specify `keys`
- Adding `Symbol` type to the language
- Adding algebraic data types to the language and supports for entities
- Adding tensors to the language which can be accessed from `scallopy`
- Adding `scallop` CLI (command-line interface) with OpenAI plugins for invoking LLMs
- Adding more documentations
- Multiple bugs fixed

# v0.1.9, Apr 24, 2023

- Supporting (partial) disjunctive Datalog
- Fixed custom provenance's default implementations and dispatcher fallback
Expand Down
11 changes: 9 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scallop-core"
version = "0.1.9"
version = "0.2.0"
authors = ["Ziyang Li <[email protected]>"]
edition = "2018"

Expand All @@ -21,10 +21,17 @@ colored = "2.0"
petgraph = "0.6"
csv = "1.1"
sprs = "0.11"
chrono = "0.4"
chrono = { version = "0.4", features = ["serde"] }
dateparser = "0.1.6"
parse_duration = "2.1.1"
dyn-clone = "1.0.10"
lazy_static = "1.4"
serde = { version = "1.0", features = ["derive"] }
rand = { version = "0.8", features = ["std_rng", "small_rng", "alloc"] }
sdd = { path = "../lib/sdd" }

# Optional ones
tch = { version = "0.13.0", optional = true }

[features]
torch-tensor = ["dep:tch"]
Empty file added core/res/.keep
Empty file.
3 changes: 3 additions & 0 deletions core/res/testing/csv/edge.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0,1
1,2
2,3
3 changes: 3 additions & 0 deletions core/res/testing/csv/edge_with_deliminator.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0 1
1 2
2 3
4 changes: 4 additions & 0 deletions core/res/testing/csv/edge_with_deliminator_and_header.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from to
0 1
1 2
2 3
4 changes: 4 additions & 0 deletions core/res/testing/csv/edge_with_header.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from,to
0,1
1,2
2,3
3 changes: 3 additions & 0 deletions core/res/testing/csv/edge_with_prob.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0.01,0,1
0.50,1,2
0.91,2,3
4 changes: 4 additions & 0 deletions core/res/testing/csv/enrollment.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
student_id,course_id,semester,year,grade
1,cse100,fa,2020,a
1,cse102,sp,2021,a
2,cse100,sp,2020,b
3 changes: 3 additions & 0 deletions core/res/testing/csv/student.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,year,gender
1,alice,2022,female
2,bob,2023,male
Empty file added core/res/testing/json/.keep
Empty file.
4 changes: 3 additions & 1 deletion core/src/common/binary_op.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! # Binary Operations
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
use serde::*;

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize)]
pub enum BinaryOp {
Add,
Sub,
Expand Down
11 changes: 11 additions & 0 deletions core/src/common/entity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

pub fn encode_entity<V: Hash, I: Iterator<Item = V>>(functor: &str, args: I) -> u64 {
let mut s = DefaultHasher::new();
functor.hash(&mut s);
for arg in args {
arg.hash(&mut s);
}
s.finish()
}
28 changes: 28 additions & 0 deletions core/src/common/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub enum Expr {
Unary(UnaryExpr),
IfThenElse(IfThenElseExpr),
Call(CallExpr),
New(NewExpr),
}

impl Expr {
Expand Down Expand Up @@ -41,6 +42,26 @@ impl Expr {
Self::Call(CallExpr { function, args })
}

pub fn new(functor: String, args: Vec<Expr>) -> Self {
Self::New(NewExpr { functor, args })
}

pub fn eq(self, other: Expr) -> Self {
Self::Binary(BinaryExpr {
op: BinaryOp::Eq,
op1: Box::new(self),
op2: Box::new(other),
})
}

pub fn neq(self, other: Expr) -> Self {
Self::Binary(BinaryExpr {
op: BinaryOp::Neq,
op1: Box::new(self),
op2: Box::new(other),
})
}

pub fn lt(self, other: Expr) -> Self {
Self::Binary(BinaryExpr {
op: BinaryOp::Lt,
Expand Down Expand Up @@ -98,6 +119,7 @@ impl Expr {
(Self::Unary(u), e) => Self::unary(u.op.clone(), u.op1.compose(e)),
(Self::IfThenElse(i), e) => Self::ite(i.cond.compose(e), i.then_br.compose(e), i.else_br.compose(e)),
(Self::Call(c), e) => Self::call(c.function.clone(), c.args.iter().map(|a| a.compose(e)).collect()),
(Self::New(n), e) => Self::new(n.functor.clone(), n.args.iter().map(|a| a.compose(e)).collect()),
}
}
}
Expand Down Expand Up @@ -291,3 +313,9 @@ pub struct CallExpr {
pub function: String,
pub args: Vec<Expr>,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct NewExpr {
pub functor: String,
pub args: Vec<Expr>,
}
Loading

0 comments on commit bfcad12

Please sign in to comment.