Skip to content

Saving models to PHAR file results in error #340

Open
@nviet

Description

@nviet

Hi there. First of all I'd like to thank you for this library as I have been playing with it to learn Machine Learning for quite some time.

So today I wanted to save the models to a PHAR file, I tried this:

$persister = new Filesystem("phar://model.phar/model.rbx", false);
$serializer = new RBX(6);
$encoding = $serializer->serialize($persistable);
$persister->save($encoding);

Then I got the Exception message Could not write to the filesystem. The reason is because of this line in the file Persisters/Filesystem.php:

$success = file_put_contents($this->path, $encoding->data(), LOCK_EX);

The flag LOCK_EX can only be used if the file is within local filesystem (the file wrapper must start with file://). Other than that, PHP will throw a warning message Exclusive locks may only be set for regular files as defined in its source code file.c.

So if anyone tries to save the models to other file wrappers such as http:// or ftp://, it will not success too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions