Skip to content

Commit

Permalink
Merge pull request #12 from baluyotraf/20230322
Browse files Browse the repository at this point in the history
Blog update and Alternative Queries
  • Loading branch information
baluyotraf authored Mar 22, 2024
2 parents 809b181 + 8886145 commit 5cb567e
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 105 deletions.
94 changes: 0 additions & 94 deletions docs/blogs/20240315-hejda-autoliv/content.md

This file was deleted.

13 changes: 13 additions & 0 deletions docs/projects/altqq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Alternative Queries

Alternative Queries is a library to help created type-checked and reusable
handcrafted SQL queries. The library also manages merging of parameters from
nested queries, making sure that the parameters are passed to your database
connection correctly.

The library is still in development and there's still no `0.1` release. If
you are curious however, feel free to check the [Alternative Queries Documentation]
and try it out by downloading the [Alternative Queries Package].

[Alternative Queries Documentation]: https://altqq.baluyotraf.com/stable/
[Alternative Queries Package]: https://pypi.org/project/altqq/
5 changes: 5 additions & 0 deletions docs/stories/.authors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
authors:
baluyotraf:
name: Raf Baluyot
description: Creator
avatar: https://avatars.githubusercontent.com/u/7478783
3 changes: 3 additions & 0 deletions docs/stories/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stories

Here are stories and updates written about software and machine learning.
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
---
authors:
- baluyotraf
date:
created: 2022-11-23
categories:
- software
---

# For Starters, How This Was Built

## Idea and Concept

I always planned to create a website, but I didn't really have the motivation
to go for it. I've always been more of the Machine Learning and back-end
person. Though I worked recently with [Jetpack Compose]. Pretty fun!
person. Though, I worked recently with [Jetpack Compose]. Pretty fun!

<!-- more -->

Well, speaking of websites, surprisingly I made a lot of them. But these are
the documentation websites for the APIs and library I developed. So my idea
is to leverage these tools so I can have some things to start with, the build
is to leverage these tools, so I can have some things to start with, the build
things from there. *You know, the agile way.*

<figure markdown>
Expand All @@ -27,7 +38,7 @@ alternatives that worked well with other pages. And from there I found
[MkDocs].

[MkDocs] uses markdown files in order to create documentation. This is
something familiar as most `README` files are written in markdown.
something familiar, as most `README` files are written in Markdown.

[MkDocs] also has a theme called [MkDocs Material]. It looks good and has a
lot of customization options that are available. I am so impressed with how
Expand All @@ -38,7 +49,7 @@ much it provides out of the box.

The code is hosted in [GitHub], so it was easy to go for deploying it in
[GitHub Pages] with [GitHub Actions]. Documentations are mostly static web
pages so [GitHub Pages] are enough for it. For CI, [MkDocs] and
pages, so [GitHub Pages] are enough for it. For CI, [MkDocs] and
[MkDocs Material] have you covered with their [GitHub Actions] support and
examples.

Expand Down
80 changes: 80 additions & 0 deletions docs/stories/posts/20240315-hejda-autoliv/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
authors:
- baluyotraf
date:
created: 2024-03-15
updated: 2024-03-22
categories:
- software
- machine-learning
---

# Hejdå Autoliv!

Today, March 15, 2024, I spent my last day in Autoliv. I went to the Vårgårda
office to meet my colleagues from research and gave everyone thanks. In
return, I also got a lot of compliments. Oh, and there's some project where my
input was appreciated.

<!-- more -->

Thinking about it, my contract lasted for 1 year and 10 months. And I thought
it would be nice to look back at the things I've done with the team.

## Software Services

A lot of the things we did in research are software driven, without going to
details of the services, here are the things I added to those services.

* Database Migrations, Proper Indexing and Constraints
* RESTful APIs
* Kotlin Multiplatform SDK for iOS/Android
* Android Application
* ServiceNow and Azure AD Integration (OpenIDC)
* Pre-commit and CI Pipelines
* Reusable CI Templates
* Automated Documentations
* Full Unit and Integration Test Suite via Docker Compose
* Security Review
* Data Migration Script

## E-Safe Pre-Study and Other Research

Electric powered mobility solutions has been gaining popularity. After coming
to Autoliv, I had to work on a research project for Vinnova. The paper is
available in the [Vinnova Publication] for more details.

In the project, we got a lot of data from electric scooters with front facing
cameras. My main contribution to the project are the computer vision outputs.
This means working mostly on object detection, distance estimation, object
tracking, and video stabilization. Below are some of the examples of the data
we processed, as shown in the paper.

![E-safe Pre-study](assets/esafe.png)

Aside from this, there are also other internal researches that I've been a part
of, both with employees and thesis students.

[Vinnova Publication]: https://www.vinnova.se/en/p/e-safe-pre-study/

## Motorcycle Airbags

Autoliv has officially announced its [Motorcycle Airbags], and part of the work
I've done is making sure that the crash algorithm is robust and capable.

![Motorcycle](https://www.autoliv.com/sites/default/files/pr/202306017153-2.png)

[Motorcycle Airbags]: https://www.autoliv.com/press/autoliv-launch-its-first-motorcycle-airbag-2025-2132315


## Next Chapters

As I wait for my next assignment or next opportunity, I've been planning on
working on the following things.

* Continue my courses on Explainable AI and Machine Learning for Predictive
Maintenance.
* Write an open source library for typed and composable handwritten SQL
in Python. Current planned name is alternative queries (altqq).
* Keep up with the latest advancements in LLMs. Thankfully, I did work with a
chatbot company before and have the fundamentals to built my knowledge on.
77 changes: 77 additions & 0 deletions docs/stories/posts/20240322-blog-updates-and-altqq/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
authors:
- baluyotraf
date:
created: 2024-03-22
categories:
- software
- data
---

# Blog Updates and Alternative Queries

Today, I would like to announce some blog updates and the release of my SQL
helper library, Alternative Queries (altqq).

<!-- more -->

## Blog Updates

As of today, the blogs in the page are powered by MkDocs Material's blog
plugin. This means that the blog page will now have additional features such
as archive, categories, and previews. If you're interested in creating blogs,
be sure to check the [MkDocs Material Documentation]. If you're not aware how
to start, you can check the [Software+ML Code].

## Alternative Queries

If you work a lot with handcrafted SQL queries and prefer to have type-checked
parameters, and reusable queries, feel free to check my library called
Alternative Queries (altqq).

### Managing Ordered Parameters

Alternative Queries also allows you to manage your query parameters. For
example, for ODBC databases, `pyodbc` does not allow named parameter. If means
that to reuse queries, one needs to make note of the parameters, as they must
be in order. For example

```python
query1 = """SELECT * from "Users" where "Id" = ?"""
query2 = """SELECT * from "Users" where "Name" = ?"""

full_query = f"{query1} UNION ALL {query2}"
parameters = [uuid4(), "Arie"]
```

The simple above looks simple, but if `query1` takes 3 parameters, and the
`full_query` reuses 3-5 existing queries, the scenario becomes more complex.
Even in this case, there is a possibility to define `parameters` as
`["Arie", uuid4()]` if one is not careful.

### Managing Named Parameters

`psycopg` support is not yet implemented in the current version. But as an
example, `psycopg` provides named parameters. The advantage of named parameters
are obvious: no parameter repetition, and more context from parameter names.

```python
query1 = """SELECT * from "Users" where "Id" = %(id)s"""
query2 = """SELECT * from "Users" where "Name" = %(name)s"""

full_query = f"{query1} UNION ALL {query2}"
parameters = {"id": uuid4(), "name": "Arie"}
```

This solution already looks better. There's no way of mistaking the query
parameters, even if the queries are merged improperly. However, this can be
an issue if the queries are complex and a lot of reuse is required. It is
possible to merge different queries that require the same name.

If you find these problems interesting, check the [Alternative Queries Documentation]
and play around it by downloading the [Alternative Queries Package].

[MkDocs Material Documentation]: https://squidfunk.github.io/mkdocs-material/
[Software+ML Code]: https://github.com/baluyotraf/softwareplusml
[Alternative Queries Documentation]: https://altqq.baluyotraf.com/stable/
[Alternative Queries Package]: https://pypi.org/project/altqq/
13 changes: 10 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,25 @@ copyright: Copyright &copy; 2024 Raffaello Baluyot

nav:
- Home: index.md
- Blogs:
- blogs/20240315-hejda-autoliv/content.md
- blogs/20221123-for-starters-how-this-was-built/content.md
- Stories:
- stories/index.md
- Projects:
- Alternative Queries: projects/altqq.md
- Education: projects/education.md

plugins:
- include-markdown
- search
- social
- blog:
blog_dir: stories

markdown_extensions:
- md_in_html
- pymdownx.superfences
- pymdownx.highlight:
anchor_linenums: true
auto_title: true

theme:
name: material
Expand Down
9 changes: 5 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CairoSVG==2.5.2
mkdocs==1.4.2
CairoSVG==2.7.1
mkdocs==1.5.3
mkdocs-include-markdown-plugin==3.9.1
mkdocs-material==8.5.8
Pillow==9.3.0
mkdocs-material==9.5.14
mkdocs-material-extensions==1.3.1
Pillow==10.2.0

0 comments on commit 5cb567e

Please sign in to comment.