Code Monkey home page Code Monkey logo

carica's Introduction

Trimatix | Jasper Law ๐Ÿซ

GitHub rรฉsumรฉ

๐ŸŽฏ BASED template project for discord.py
๐ŸŒ‘ BountyBot fan game for Galaxy on Fire 2
๐Ÿค– AI with tensorflow - esports analytics research in DOTA 2
๐Ÿƒ Carica python configurator library
๐ŸŽง Downtempo electronic music producer @Trimatix

Interests

Data Analysis & Visualization - Compilers - Game Development (Unreal Engine)

Currently working on...

What's next...

  1. BountyBot 1.0 release
  2. Game engine in c++
    • Basic space game
  3. GOFCMM/GOFShark (cross-platform GOF2 mod manager w/ tuari)
    • Universe mod - swap all assets, item definitions, dialog, galactic map, and possibly even sounds/music, for a new story in an existing universe e.g star wars/star trek/everspace/freelancer

Languages

In descending order of experience:

  • Python 3 (mypy/pyright)
  • C# (.NET 8)
  • Java
  • C++
  • JavaScript (TypeScript)

Contact

๐ŸŽฎ Discord: Trimatix

๐Ÿ’ฌ AMA


My GitHub Statistics
My Discord Bots

carica's People

Contributors

trimatix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

carica's Issues

Async serializer

This may well require a separate package to keep the synchronous version fast

Allow async serialize/deserialize

Serialize failure callback

Allow a model's serialize to fail partially by adding a callback parameter. E.g SerializableDataclass attempts to serialize each Serializable field. If one throws an exception, pass it to the callback, then carry ok serializing the others.

#6 would be ideal for this

`Required[x]` type hint

Placed on a variable in cfg to require that the variable be specified in TOML. x could be an Optional allowing the variable to still be given as null, but it must be supplied as such in TOML, not just left to its default.

installer does not work

to reproduce:

  1. python -m pip install carica
  2. python
  3. import carica
  4. observe error
  5. import tomlkit
  6. observe error

Serialize-to-type type hints

It's annoying to have to write my own type hints to guarantee that my types with serialize to dict

TSelf = TypeVar("TSelf", bound="SerializesToType")
TSerialized = TypeVar("TSerialized", bound="PrimativeType")

class SerializesToType(Generic[TSerialized]):
    def serialize(self, **kwargs) -> TSerialized: ...

    @classmethod
    def deserialize(cls: Type[TSelf], data: TSerialized, **kwargs) -> TSelf: ..

x: SerializesToType[Dict[str, PrimativeType]] = MyClass()
y: Dict[str, PrimativeType] = x.serialize()

SerializableDict

Just inherit dict but with value auto-serializing serialize/deserialize methods (similar to SerializableDataclass)

JsonProperty decorator

effectively makes your class work like a serializabledataclass

Stack on top of a @property call to mark a property as a field in the objects serialised JSON

Probably also include "JSON property name override" and "required" params

Config section comments

Configurable comment prefix that will make a comment detected as a section/header (e.g "###")

These are saved to file

Need to consider that variable ordering is NOT guaranteed, since tables must come last. One possible solution is, if a table did not come last in the module, add another copy of the must recent section/header in the module before that table

Make type hints generic

SerializableType.deserialize requires any implementing classes to return SerializableType and not their own class.

Fix this with something similar to:

TSelf = TypeVar("TSelf", bound="SerializableType")

class SerializableType(Protocol):
    def serialize(self, **kwargs) -> PrimativeType: ...

    @classmethod
    def deserialize(cls: Type[TSelf], data: PrimativeType, **kwargs) -> TSelf: ..

Load docstrings -> toml

This feature is mostly complete but tests fail under certain conditions when saving preceeding comments for structural variables (tables and arrays).

Variable is not ordering is not guaranteed. This is due to the TOML spec requiring that structural variables appear at the end of a document to resolve ambiguities in the variable heirarchy.
Since ordering is not guaranteed, and tomlkit does not explicitly know that preceeding comments are associated with variables, structural variables can be moved around during document rendering, with their preceeding comments left behind in undesirable locations in the document.

An unideal solution to this problem could make use of reflection, in a sense. A tomlkit document maintains two private fields:

  • _body: A list of (key (name), value) tuples
  • _map: A dictionary mapping a key (name) to the index of the key in _body.
    It may be possible to manipulate the rendering order of the document by manually moving the index of preceeding comments to just before the new table location. Depending on when reordering takes place, this may or may not be feasible.

there may be other easier solutions, or if all else fails, we can just manipulate the rendered string.

updateCfg

Read a config file into dict, update the values in the dict with the values in a module, but only those keys that already exist, and write the dict back to the same file including comments etc

Is there a way to preserve ALL formatting e.g added whitespace? Does tomlkit do that?

choose 'best' Union candidate instead of 'first'

in order to overcome limiting dataclass field hints to a primative Unions, all types in the union are recursed over and the first successful deserialize is accepted.

Instead, all types in the union should be attempted, and the 'best match' selected. This could be quite slow, so perhaps parameterize this in carica configuration?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.