In the middle of the desert you can say anything you want
Pydantic’s FilePath
is like Path except that the file has to exist and be a file.
BUT FilePath
when validating expects a string as input, not a Path!
(in other words: FilePath(Path)
doesn’t seem to work)
So when I create a Validator that converts str
into Path
1:
@field_validator("filename", mode="before")
@classmethod
def parse_filename(cls, value: str | Path) -> Path:
return Path(value)
I get a wonderful
> doc = UCFDocument.model_validate_json(json_string)
E pydantic_core._pydantic_core.ValidationError: 1 validation error for UCFDocument
E filename
E Input is not a valid path for <class 'pathlib.Path'> [type=path_type, input_value=PosixPath('/home/sh/w/cor...n/doc.pdf_data/doc.pdf'), input_type=PosixPath]
tests/ucf/test_data_structures.py:179: ValidationError
Again, the error is a PosixPath
not being a Path, though it is one:
E Input is not a valid path for <class 'pathlib.Path'> [type=path_type, input_value=PosixPath('/home/sh/w/cor...n/doc.pdf_data/doc.pdf'), input_type=PosixPath]
# explicitly expecting a PosixPath creates an even better
E Input is not a valid path for <class 'pathlib.PosixPath'> [type=path_type, input_value=PosixPath('/home/sh/w/cor...n/doc.pdf_data/doc.pdf'), input_type=PosixPath]
Not intuitive at all.
Solution is to give FilePath strings and only strings, or drop FilePath
to begin with.
├── pydantic v2.10.6
│ ├── annotated-types v0.7.0
│ ├── pydantic-core v2.27.2
│ │ └── typing-extensions v4.12.2
(don’t ask why I needed this, this is a minimal reproducible example only) ↩︎
CVAT is a really neat labelling platform, online + free on-premise w/ Docker.
(Github: cvat-ai/cvat: Annotate better with CVAT, the industry-leading data engine for machine learning. Used and trusted by teams at any scale, for data of any scale.)
I like it more than label studio for images, has more functions, but is also “heavier” / bulkier.
Love how it supports even 600mb 4-channel TIFF satellite images and is quite fast at that.
Bits:
<C-a>
for snipping polygons to existing polygon ponitsThe Open LLM Leaderboard is dead1, as good time as any to look for new eval stuff!
HF universe
Harnesses
Resources / articles:
The easy stupid way for backing up gitea running in docker, untested and allegedly will fail if DB was being used during dumping.
docker exec -it --user git gitea-container bash
gitea dump
# then outside the container, copy from the gitea container to host OSooj
docker cp gitea-container:/whatveer/gitea-dump.zip /tmp
Importing: the docs don’t have the correct paths, not easy to follow.
EDIT: if your docker has /data
mounted somewhere local, just copying that directory somewhere might work.
CLI:
sudo lshw -C disk
tells you all disks
h
In fsspec fs.copy()
doesn’t really work from local to remote, also existing or not-existing directories etc.
Their documentation has a whole page on this: Copying files and directories — fsspec 2024.10.0.post13+gdbed2ec.d20241115 documentation
GitLab CLI - glab
| GitLab Docs: CLI thingy to interact with gitlab.
TL;DR: glab ci status
or whatever.
It’s really neat and has a cool CLI interface, either you set things through flags or you get a neat menu to choose from!
Smart enough to parse current directory!
Git Tag: A Tutorial for Tagging Releases in Git - DEV Community
#ligthweight tag
git tag v1.0.0
# full
git tag -a v1.0.0 -m "Releasing version v1.0.0"
Tags don’t get pushed automatically. For this,
git push origin v1.0.0
uv
uses hatch
which has this to say about dynamic versioning: Configuring project metadata - Hatch[project]
dynamic = ["version"]
[tool.hatch.version]
path = "..."
Path is a python file w/ version info. If using src
layout, src
has to be included in the path.j
For uv, this works. Described for example here: Versioning Python Projects with Hatch
(I like __init__.py
though, not about as that guide does)
uv-dynamic-versioning · PyPI exists but I don’t really see why.
Because every single goddamn time
Command line: How do you rotate a PDF file 90 degrees? - Unix & Linux Stack Exchange
pdftk input.pdf cat 1-endwest output output.pdf
1-
is needed because page range, here for all pages.
endwest
etc from man page:
[<begin page number>[-<end page number>[<qualifier>]]][<page rotation>]
The qualifier can be even or odd, and the page rotation can be north, south, east, west, left, right, or down.
Each option sets the page rotation as follows (in degrees): north: 0, east: 90, south: 180, west: 270, left: -90, right: +90, down: +180. left, right, and down make relative adjustments to a page’s rotation.