-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from maxfordham/configure-pixi
Configure pixi
- Loading branch information
Showing
30 changed files
with
5,517 additions
and
1,239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# GitHub syntax highlighting | ||
pixi.lock linguist-language=YAML linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: monthly | ||
groups: | ||
dependencies: | ||
patterns: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# TODO: setup auto-update pixi.lock https://pixi.sh/latest/advanced/updates_github_actions/#how-to-use | ||
|
||
name: Test and Lint | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
label: linux-64 | ||
|
||
name: ${{ matrix.label }} | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: prefix-dev/[email protected] | ||
with: | ||
manifest-path: pyproject.toml | ||
pixi-version: v0.30.0 | ||
cache: true | ||
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | ||
- run: pixi run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "4dfb0c9b-81b1-4d02-a51d-218309cf20dd", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"{'event_datetime': {'start': datetime.datetime(2024, 1, 1, 15, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 1, 3, 14, 0, tzinfo=datetime.timezone.utc), 'aware_datetime': datetime.datetime(1, 2, 3, 0, 1, 15, tzinfo=datetime.timezone.utc), 'deltat': datetime.timedelta(days=1, seconds=2), 'time_of_date': datetime.time(12, 45), 'inty': 1}}\n", | ||
"{\"event_datetime\":{\"start\":\"2024-01-01T07:00:00-08:00\",\"end\":\"2024-01-03T20:00:00+06:00\",\"aware_datetime\":\"0001-02-03T00:00:00\",\"deltat\":\"P1DT2S\",\"time_of_date\":\"12:45:00\",\"inty\":1}}\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from datetime import datetime, time, timedelta, timezone\n", | ||
"from typing import Any, Dict\n", | ||
"\n", | ||
"from pydantic import AwareDatetime, BaseModel, WrapSerializer\n", | ||
"from typing_extensions import Annotated\n", | ||
"\n", | ||
"\n", | ||
"class EventDatetime(BaseModel):\n", | ||
" start: datetime\n", | ||
" end: datetime\n", | ||
" aware_datetime: AwareDatetime = datetime(1, 2, 3)\n", | ||
" deltat: timedelta = timedelta(1, 2)\n", | ||
" time_of_date: time = time(12, 45)\n", | ||
" inty: int = 1\n", | ||
"\n", | ||
"\n", | ||
"def convert_to_utc(value: Any, handler, info) -> Dict[str, Any]:\n", | ||
" # Note that `helper` can actually help serialize the `value` for further custom serialization in case it's a subclass.\n", | ||
" partial_result = handler(value, info)\n", | ||
" fn = (\n", | ||
" lambda v: \"datetime.fromisoformat(v).astimezone(timezone.utc)\"\n", | ||
" if isinstance(v, datetime)\n", | ||
" else v\n", | ||
" )\n", | ||
" if info.mode == \"json\":\n", | ||
" return {k: fn(v) for k, v in partial_result.items()}\n", | ||
" fn = lambda v: v.astimezone(timezone.utc) if isinstance(v, datetime) else v\n", | ||
" return {k: fn(v) for k, v in partial_result.items()}\n", | ||
"\n", | ||
"\n", | ||
"UTCEventDatetime = Annotated[EventDatetime, WrapSerializer(convert_to_utc)]\n", | ||
"\n", | ||
"\n", | ||
"class EventModel(BaseModel):\n", | ||
" event_datetime: UTCEventDatetime\n", | ||
"\n", | ||
"\n", | ||
"dt = EventDatetime(start=\"2024-01-01T07:00:00-08:00\", end=\"2024-01-03T20:00:00+06:00\")\n", | ||
"event = EventModel(event_datetime=dt)\n", | ||
"print(event.model_dump())\n", | ||
"\"\"\"\n", | ||
"{\n", | ||
" 'event_datetime': {\n", | ||
" 'start': datetime.datetime(\n", | ||
" 2024, 1, 1, 15, 0, tzinfo=datetime.timezone.utc\n", | ||
" ),\n", | ||
" 'end': datetime.datetime(\n", | ||
" 2024, 1, 3, 14, 0, tzinfo=datetime.timezone.utc\n", | ||
" ),\n", | ||
" }\n", | ||
"}\n", | ||
"\"\"\"\n", | ||
"\n", | ||
"print(event.model_dump_json())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "2f022b81-38f1-43af-a5c0-18bbd964a040", | ||
"metadata": {}, | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
https://github.com/frictionlessdata/frictionless-py/issues/1678 | ||
```{python} | ||
import pandas as pd | ||
x = range(0, 5) | ||
y = [_**2 for _ in x] | ||
z = [_*1.2 for _ in x] | ||
df = pd.DataFrame({"x": x, "y": y, "z": z}) | ||
from frictionless import Resource | ||
r = Resource(df) | ||
r.read_rows() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
|
||
## Execution | ||
|
||
```{mermaid} | ||
stateDiagram | ||
[*] --> Still | ||
[*1*] --> Still | ||
Still --> [*] | ||
Still --> Moving | ||
Moving --> Still | ||
Moving --> Crash | ||
Crash --> [*] | ||
Crash --> [some] | ||
``` | ||
|
||
```{python} | ||
from frictionless import Resource, formats | ||
resource = Resource(data=[['id', 'name'], [1, 'english'], [2, 'german']]) | ||
resource.write('table-output-sheet.xls', control=formats.ExcelControl(sheet='My Table')) | ||
``` | ||
|
||
|
||
```{python} | ||
a = "" | ||
issubclass(a, str) | ||
``` | ||
|
Oops, something went wrong.