From a853106ba7d21a92a2a25ce64c9848caf6eb473b Mon Sep 17 00:00:00 2001 From: Anatoly Bugakov Date: Tue, 26 Dec 2023 12:33:53 +0000 Subject: [PATCH 1/2] unifying LICENSE and README across repo --- LICENSE | 55 ++----------- README.md | 138 +++++++++++++++++++------------ pyultima/LICENSE | 18 +---- pyultima/README.md | 196 +-------------------------------------------- 4 files changed, 94 insertions(+), 313 deletions(-) diff --git a/LICENSE b/LICENSE index 1980f9c9..60fafd03 100644 --- a/LICENSE +++ b/LICENSE @@ -3,56 +3,15 @@ Parameters Licensor: Ultibi Ltd. Licensed Work: Ultima The Licensed Work is (c) 2023 Ultibi Ltd. +### License +`ultibi` python library is made available for the purpose of demonstrating the possibilities offered by the Software so users can evaluate the possibilities and potential of the Software. You can choose one of the following: -Abstract -Ultibi users can run it as a service, make availiable to their employees, contractors, and subsidiary companies. They can extend Ultibi with their own Measures applied to their DataSets. They can use Ultibi to present their data to their consumers. The only thing that Ultibi users will not be able to do is offer a commercial version of Ultibi as Analytics as a Service without buying a license. For information about alternative licensing arrangements for the Software, -please visit: https://ultimabi.uk/ +1) [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html) -`Ultibi as Analytics as a Service` is a commercial offering that allows third parties (other than your employees andcontractors) to make use of the setup and Measures defined by that who makes the offer or other third parties. +2) Proprietary License. Allows you to use the software in whichever way you want. These `licenses` are extremely affordable, and you can check out the options by reaching out to us directly, via `anatoly at ultimabi dot uk`, or by visiting `ultimabi dot uk` -Acceptance -By using the software, you agree to all of the terms and conditions below. - -Copyright License -The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and tailor derivative works of the software, in each case subject to the limitations and conditions below. - -Limitations -You may not make the functionality of the software or a modified version available to third parties as a service, or distribute the software or a modified version in a manner that makes the functionality of the software available to third parties. - -Making the functionality of the software or modified version available to third parties includes, without limitation, enabling third parties to interact with the functionality of the software or modified version in distributed form or remotely through a computer network, offering a product or service the value of which entirely or primarily derives from the value of the software or modified version, or offering a product or service that accomplishes for users the primary purpose of the software or modified version. - -You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law. - -Patents -The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company. - -Notices -You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms. - -If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software. - -No Other Rights -These terms do not imply any licenses other than those expressly granted in these terms. - -Termination -If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violations of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently. - -No Liability +### No Liability As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim. -Definitions -The licensor is the entity offering these terms, and the software is the software the licensor makes available under these terms, including any portion of it. - -To modify a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission other than making an exact copy. The resulting work is called a modified version of the earlier work. - -you refers to the individual or entity agreeing to these terms. - -your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. - -control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect. - -your licenses are all the licenses granted to you for the software under these terms. - -use means anything you do with the software requiring one of your licenses. - -trademark means trademarks, service marks, and similar rights. \ No newline at end of file +### Contributions +All code in this Repository is a property of the Licensor. If you make a contribution via PR or any other way, you give the Licensor a right to use your code in whatever way they deem necessary, including copying or refactoring it to a private repository, provided that a copy of your work will remain available under the current conditions. diff --git a/README.md b/README.md index 6c82d4d0..a55633b6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

- Ultima Logo + Ultima Logo


@@ -18,7 +18,7 @@ With `Ultibi` you can turn your `DataFrame` into a pivot table with a UI and sha

- Ultima Logo + Ultima Logo

@@ -28,11 +28,12 @@ Ultibi leverages on the giants: [Actix](https://github.com/actix/actix-web), [Po # Examples -Our userguide is under development. -In the mean time refer to FRTB [userguide](https://ultimabi.uk/ultibi-frtb-book/). +Our [userguide](https://ultimabi.uk/ultibi-frtb-book/) ## Python +`pip install ultibi` +### Quickstart ```python import ultibi as ul import polars as pl @@ -44,6 +45,31 @@ os.environ["ADDRESS"] = "0.0.0.0:8000" # host on this address # for more details: https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.read_csv.html df = pl.read_csv("titanic.csv") +# Convert it into an Ultibi DataSet +ds = ul.DataSet.from_frame(df) + +# By default (might change in the future) +# Fields are Utf8 (non numerics) and integers +# Measures are numeric columns. +ds.ui() +``` + +Then navigate to `http://localhost:8000` or checkout `http://localhost:8000/swagger-ui` for the OpenAPI documentation. + +### More flexible - custom measures +```python +import ultibi as ul +import polars as pl +import os +os.environ["RUST_LOG"] = "info" # enable logs +os.environ["ADDRESS"] = "0.0.0.0:8000" # host on this address + +# Read Data +# for more details: https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.read_csv.html +df = pl.read_csv("titanic.csv") + +# Let's add some Custom/Bespoke Calculations to our UI + # Standard Calculator def survival_mean_age(kwargs: dict[str, str]) -> pl.Expr: """Mean Age of Survivals @@ -53,6 +79,11 @@ def survival_mean_age(kwargs: dict[str, str]) -> pl.Expr: """ return pl.col("age") * pl.col("survived") / pl.col("survived").sum() +# Also a Standard Calculator +def example_dep_calc(kwargs: dict[str, str]) -> pl.Expr: + return pl.col("SurvivalMeanAge_sum") + pl.col("SouthamptonFareDivAge_sum") + +# When we need more involved calculations we go for a Custom Calculator def custom_calculator( srs: list[pl.Series], kwargs: dict[str, str] ) -> pl.Series: @@ -68,14 +99,8 @@ def custom_calculator( res = df["S"] * df["fare"] / df["age"] * multiplier return res -def example_dep_calc(kwargs: dict[str, str]) -> pl.Expr: - return pl.col("SurvivalMeanAge_sum") + pl.col("SouthamptonFareDivAge_sum") - # inputs for the custom_calculator srs param inputs = ["age", "fare", "embarked"] -# (Optional) - we are only interested in Southampton -# unless other measures requested -precompute_filter = ul.EqFilter("embarked", "S") # We return Floats res_type = pl.Float64 # We return a Series, not a scalar (which otherwise would be auto exploded) @@ -87,7 +112,11 @@ measures = [ ul.CustomCalculator( custom_calculator, res_type, inputs, returns_scalar ), - [[precompute_filter]], + # (Optional) - we are only interested in Southampton, so + # unless other measures requested we might as well filter for Southampton only + # However, if if multiple measures requested, their precompute_filters will be joined as OR. + [[ul.EqFilter("embarked", "S")]], + # PARAMS tab of the UI calc_params=[ul.CalcParam("mltplr", "1", "float")] ), ul.BaseMeasure( @@ -108,56 +137,59 @@ ds = ul.DataSet.from_frame(df, bespoke_measures=measures) # By default (might change in the future) # Fields are Utf8 (non numerics) and integers # Measures are numeric columns. -ds.ui() +ds.ui() ``` -Then navigate to `http://localhost:8000` or checkout `http://localhost:8000/swagger-ui` for the OpenAPI documentation. +You can also wite Rust native Custom calculators measure which wouldn't be bounded by GIL! Checkout the [userguide](https://ultimabi.uk/ultibi-frtb-book/). -## Rust -Note: currently if you want to use inbuild functionality of the .ui() method (instead of using a template like [template_drivers](https://github.com/ultima-ib/ultima/tree/master/template_drivers)) you have to -1. Build Frontend -```shell -cd frontend -npm run build +### DataSources - In and OutOf memory +We provide aim to support different sources of the data. +```python +scan = pl.read_csv("../frtb_engine/data/frtb/Delta.csv", + dtypes={"SensitivitySpot": pl.Float64}) +dsource = ul.DataSource.inmemory(scan) +ds = ul.DataSet.from_source(dsource) +ds.prepare() # .prepare() is only relevant to FRTB dataset currently +ds.ui() ``` -2. Set up env variable **STATIC_FILES_DIR**="{your_path}\frontend\dist" - -3. -```rust -use std::sync::Arc; -use std::sync::RwLock; - -use polars::prelude::LazyCsvReader; -use ultibi::DataSet; -use ultibi::DataSetBase; -use ultibi::VisualDataSet; -use std::env; - -pub fn example() { - // See logs - env::set_var("RUST_LOG", "info"); - - // Read df - let df = LazyCsvReader::new("titanic.csv") - .finish() - .unwrap(); - - // Conver df into Arc> - let ds: Arc> = Arc::new(RwLock::new( - DataSetBase::new(df, Default::default(), Default::default()) - )); - - // Visualise - ds.ui(false); -} +If you don't want to/can't hold all your data in the process memory, you can sacrifise performance for memory with Scan/DataBase +```python +import polars as pl +import ultibi as ul +# Note that the LazyFrame query must start with scan_ +# and must've NOT been collected +scan = pl.scan_csv("../frtb_engine/data/frtb/Delta.csv", + dtypes={"SensitivitySpot": pl.Float64}) +dsource = ul.DataSource.scan(scan) +ds = ul.DataSet.from_source(dsource) +ds.ui() ``` -`cargo run --release` +Note: Naturally the later two options will be slower, because prior to computing your measures we will need to read the relevant bits of the data into the process memory. ### FRTB SA [FRTB SA](https://en.wikipedia.org/wiki/Fundamental_Review_of_the_Trading_Book) is a great usecase for `ultibi`. FRTB SA is a set of standardised, computationally intensive rules established by the regulator. High business impact of these rules manifests in need for **analysis** and **visibility** thoroughout an organisation. Note: Ultima is not a certified aggregator. Always benchmark the results against your own interpretation of the rules. See python frtb [userguide](https://ultimabi.uk/ultibi-frtb-book/). -## Bespoke Hosting -You don't have to use `.ui()`. You can write your own sevrer easily based on your needs (for example DB interoperability for authentication) -See an example [template_drivers](https://github.com/ultima-ib/ultima/tree/master/template_drivers) bin server. +### Polars Compatibility +| Ultibi | Polars | +| ----------- | ----------- | +| 0.5 | 18.7 | +| 0.6 | 19.18 | + +### License +Licensor: Ultibi Ltd. +Licensed Work: Ultima + The Licensed Work is (c) 2023 Ultibi Ltd. + +`ultibi` python library is made available for the purpose of demonstrating the possibilities offered by the Software so users can evaluate the possibilities and potential of the Software. You can choose one of the following: + +1) [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html) + +2) Proprietary License. Allows you to use the software in whichever way you want. These `licenses` are extremely affordable, and you can check out the options by reaching out to us directly, via `anatoly at ultimabi dot uk`, or by visiting `ultimabi dot uk` + +### No Liability +As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim. + +### Contributions +All code in this Repository is a property of the Licensor. If you make a contribution via PR or any other way, you give the Licensor a right to use your code in whatever way they deem necessary, including copying or refactoring it to a private repository, provided that a copy of your work will remain available under the current conditions. \ No newline at end of file diff --git a/pyultima/LICENSE b/pyultima/LICENSE index 60fafd03..ea5b6064 100644 --- a/pyultima/LICENSE +++ b/pyultima/LICENSE @@ -1,17 +1 @@ -Parameters - -Licensor: Ultibi Ltd. -Licensed Work: Ultima - The Licensed Work is (c) 2023 Ultibi Ltd. -### License -`ultibi` python library is made available for the purpose of demonstrating the possibilities offered by the Software so users can evaluate the possibilities and potential of the Software. You can choose one of the following: - -1) [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html) - -2) Proprietary License. Allows you to use the software in whichever way you want. These `licenses` are extremely affordable, and you can check out the options by reaching out to us directly, via `anatoly at ultimabi dot uk`, or by visiting `ultimabi dot uk` - -### No Liability -As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim. - -### Contributions -All code in this Repository is a property of the Licensor. If you make a contribution via PR or any other way, you give the Licensor a right to use your code in whatever way they deem necessary, including copying or refactoring it to a private repository, provided that a copy of your work will remain available under the current conditions. +../LICENSE \ No newline at end of file diff --git a/pyultima/README.md b/pyultima/README.md index a55633b6..32d46ee8 100644 --- a/pyultima/README.md +++ b/pyultima/README.md @@ -1,195 +1 @@ -
- -

- - Ultima Logo - -

-
- -

the ultimate data analytics tool
for no code visualisation and collaborative exploration.

- -

Present easier.   Dig deeper.   Review together.  

- -# The Ultimate BI tool -With `Ultibi` you can turn your `DataFrame` into a pivot table with a UI and share it across organisation. You can also define measures applicable to your `DataFrame`. This means your colleagues/consumers don't have to write any code to analyse the data. - -
- -

- - Ultima Logo - -

- -
- -Ultibi leverages on the giants: [Actix](https://github.com/actix/actix-web), [Polars](https://github.com/pola-rs/polars) and Rust which make this possible. We use TypeScript for the frontend. - -# Examples - -Our [userguide](https://ultimabi.uk/ultibi-frtb-book/) - -## Python -`pip install ultibi` - -### Quickstart -```python -import ultibi as ul -import polars as pl -import os -os.environ["RUST_LOG"] = "info" # enable logs -os.environ["ADDRESS"] = "0.0.0.0:8000" # host on this address - -# Read Data -# for more details: https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.read_csv.html -df = pl.read_csv("titanic.csv") - -# Convert it into an Ultibi DataSet -ds = ul.DataSet.from_frame(df) - -# By default (might change in the future) -# Fields are Utf8 (non numerics) and integers -# Measures are numeric columns. -ds.ui() -``` - -Then navigate to `http://localhost:8000` or checkout `http://localhost:8000/swagger-ui` for the OpenAPI documentation. - -### More flexible - custom measures -```python -import ultibi as ul -import polars as pl -import os -os.environ["RUST_LOG"] = "info" # enable logs -os.environ["ADDRESS"] = "0.0.0.0:8000" # host on this address - -# Read Data -# for more details: https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.read_csv.html -df = pl.read_csv("titanic.csv") - -# Let's add some Custom/Bespoke Calculations to our UI - -# Standard Calculator -def survival_mean_age(kwargs: dict[str, str]) -> pl.Expr: - """Mean Age of Survivals - pl.col("survived") is 0 or 1 - pl.col("age") * pl.col("survived") - age of survived person, otherwise 0 - pl.col("survived").sum() - number of survived - """ - return pl.col("age") * pl.col("survived") / pl.col("survived").sum() - -# Also a Standard Calculator -def example_dep_calc(kwargs: dict[str, str]) -> pl.Expr: - return pl.col("SurvivalMeanAge_sum") + pl.col("SouthamptonFareDivAge_sum") - -# When we need more involved calculations we go for a Custom Calculator -def custom_calculator( - srs: list[pl.Series], kwargs: dict[str, str] - ) -> pl.Series: - """ - Southampton Fare/Age*multiplier - """ - df = pl.DataFrame({"age": srs[0], - "fare": srs[1], - "e": srs[2]}) - # Add Indicator Column for Southampton - df = df.with_columns(pl.when(pl.col("e")=="S").then(1).otherwise(0).alias("S")) - multiplier = float(kwargs.get("multiplier", 1)) - res = df["S"] * df["fare"] / df["age"] * multiplier - return res - -# inputs for the custom_calculator srs param -inputs = ["age", "fare", "embarked"] -# We return Floats -res_type = pl.Float64 -# We return a Series, not a scalar (which otherwise would be auto exploded) -returns_scalar = False - -measures = [ - ul.BaseMeasure( - "SouthamptonFareDivAge", - ul.CustomCalculator( - custom_calculator, res_type, inputs, returns_scalar - ), - # (Optional) - we are only interested in Southampton, so - # unless other measures requested we might as well filter for Southampton only - # However, if if multiple measures requested, their precompute_filters will be joined as OR. - [[ul.EqFilter("embarked", "S")]], - # PARAMS tab of the UI - calc_params=[ul.CalcParam("mltplr", "1", "float")] - ), - ul.BaseMeasure( - "SurvivalMeanAge", - ul.StandardCalculator(survival_mean_age), - aggregation_restriction="sum", - ), - ul.DependantMeasure( - "A_Dependant_Measure", - ul.StandardCalculator(example_dep_calc), - [("SurvivalMeanAge", "sum"), ("SouthamptonFareDivAge", "sum")], - ), - ] - -# Convert it into an Ultibi DataSet -ds = ul.DataSet.from_frame(df, bespoke_measures=measures) - -# By default (might change in the future) -# Fields are Utf8 (non numerics) and integers -# Measures are numeric columns. -ds.ui() -``` - -You can also wite Rust native Custom calculators measure which wouldn't be bounded by GIL! Checkout the [userguide](https://ultimabi.uk/ultibi-frtb-book/). - -### DataSources - In and OutOf memory -We provide aim to support different sources of the data. -```python -scan = pl.read_csv("../frtb_engine/data/frtb/Delta.csv", - dtypes={"SensitivitySpot": pl.Float64}) -dsource = ul.DataSource.inmemory(scan) -ds = ul.DataSet.from_source(dsource) -ds.prepare() # .prepare() is only relevant to FRTB dataset currently -ds.ui() -``` -If you don't want to/can't hold all your data in the process memory, you can sacrifise performance for memory with Scan/DataBase -```python -import polars as pl -import ultibi as ul -# Note that the LazyFrame query must start with scan_ -# and must've NOT been collected -scan = pl.scan_csv("../frtb_engine/data/frtb/Delta.csv", - dtypes={"SensitivitySpot": pl.Float64}) -dsource = ul.DataSource.scan(scan) -ds = ul.DataSet.from_source(dsource) -ds.ui() -``` - -Note: Naturally the later two options will be slower, because prior to computing your measures we will need to read the relevant bits of the data into the process memory. - -### FRTB SA -[FRTB SA](https://en.wikipedia.org/wiki/Fundamental_Review_of_the_Trading_Book) is a great usecase for `ultibi`. FRTB SA is a set of standardised, computationally intensive rules established by the regulator. High business impact of these rules manifests in need for **analysis** and **visibility** thoroughout an organisation. Note: Ultima is not a certified aggregator. Always benchmark the results against your own interpretation of the rules. -See python frtb [userguide](https://ultimabi.uk/ultibi-frtb-book/). - -### Polars Compatibility -| Ultibi | Polars | -| ----------- | ----------- | -| 0.5 | 18.7 | -| 0.6 | 19.18 | - -### License -Licensor: Ultibi Ltd. -Licensed Work: Ultima - The Licensed Work is (c) 2023 Ultibi Ltd. - -`ultibi` python library is made available for the purpose of demonstrating the possibilities offered by the Software so users can evaluate the possibilities and potential of the Software. You can choose one of the following: - -1) [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html) - -2) Proprietary License. Allows you to use the software in whichever way you want. These `licenses` are extremely affordable, and you can check out the options by reaching out to us directly, via `anatoly at ultimabi dot uk`, or by visiting `ultimabi dot uk` - -### No Liability -As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim. - -### Contributions -All code in this Repository is a property of the Licensor. If you make a contribution via PR or any other way, you give the Licensor a right to use your code in whatever way they deem necessary, including copying or refactoring it to a private repository, provided that a copy of your work will remain available under the current conditions. \ No newline at end of file +../README.md \ No newline at end of file From ffc402a87b88bf6dfadb0283f11b124e13bc548d Mon Sep 17 00:00:00 2001 From: Anatoly Bugakov Date: Tue, 26 Dec 2023 12:34:16 +0000 Subject: [PATCH 2/2] [skip ci] --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 60fafd03..eba8c372 100644 --- a/LICENSE +++ b/LICENSE @@ -3,7 +3,7 @@ Parameters Licensor: Ultibi Ltd. Licensed Work: Ultima The Licensed Work is (c) 2023 Ultibi Ltd. -### License +### License `ultibi` python library is made available for the purpose of demonstrating the possibilities offered by the Software so users can evaluate the possibilities and potential of the Software. You can choose one of the following: 1) [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html)