Giter VIP home page Giter VIP logo

python-functown's People

Contributors

felixnext avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

muddi900

python-functown's Issues

Implement additional Serialization Options

Add additional serialization options, including:

  • Thrift (Compact)?
  • Protobuf
  • FlatBuf
  • Parquet
  • CSV

Provide also a MimeResponse and MimeRequest decorator that allows conditional logic.

This is an extension of #28 (introduced in v1.1.0)

Refactor Decorators into Stackable Classes

Decorators could be refactored to derive from a base class.

This could take care of certain abstractions (such as creating loggers) as well as automatically decomposing stacked operators (to avoid the @clean decorator at the outer layer.

References:

This still requires a bunch of design and depends on #10 and #9

Add Mocked Unit Tests for JWT

We do not test the verify option for JWT right now, as that would required requests against a token provider backend.

The idea is to mock the requests with realistic responses coming from a token provider and increase test coverage.

Updated Documentation for v1.0.0 release

#10 brings the lib to the alpha stage, but we should update the documentation to be up to date.

Specifically this includes:

  • Bring code in readme up to date and simplify
  • Add "Technical Debt" section to the readme
  • Create docs folder and create a page for each sub-system
  • Create a section for extension
  • Create a section for contributors

Integrate Wrapper for Telemetry Client

The Application Insights telemetry client provides various exception handling and metric tracking abilities.

It would be great to directly integrate them into FuncTown (thereby allowing to track return types, exceptions and various metrics through App Insights)

Design for this has yet to be done

Example Function

Add an example Azure Function that uses the library to display the functionality and test it more easily

Properly debug Example Functions

The functions cannot be debugged due to internal links to functown instead of functown_local when the lib is not yet deployed (since the changes are too big). Need to deploy and debug then (for now).

Add Unit Tests to MetricHandler

The MetricHandler has different modes that can be applied to the create_metrics function.

These modes are currently not covered by unit-tests.

Goal would be to cover:

  • All 4 different modes
  • Expected behavior in case of namespace conflicts
  • Proper values in metrics in case of Reuse

Integrate `Optional` typing keyword

Many parameters in different functions are optional in a sense that None can be passed to them.

The goal of this task is to properly add the Optional Type to the typing hints in all signatures

Split library into sub-modules

By adding more decorators and functions to the base library, the list of dependent imports is growing.

The goal of this issue would be to split of parts of the library into seperate sub-modules that can be installed as needed. Obvious candidates for this would be:

  • Serialization
  • Insights

The install routine should then look like this:

pip install functown
pip install functown[insights]
pip install functown[serialization]

Provide Response Decorators

This goes into the same direction as #5

It would be great to remove response boilerplate code from functions.

# current
def main(req):
  # ...
  data = {...}
  return HttpResponse(json.dumps(data), mimetype="application/json", status_code=200)

# updated
@json
def main(req):
  # ...
  return data

The json decorator might take optional parameters such as status_code. Should also be possible to extend to different structures later on (e.g. protobuf(pb=Obj) or multi which takes a Return object that contains the mimetype).

In particular mutli would allow to handle requests from #5 .

Implement logger from Example

Depends on changes in #8

In that PR a logger is introduced that writes all log messages to a list.
Explore if that can be leveraged as a tag to ensure that we can also return all logs in the response!

`is_first_decorator` can be flaky

When many decorators are used in parallel (in unittests for example) the is_first_decorator system can be flaky (maybe due to collisions in the id(func) space?).

This forced to enable the removal of variable keyword parameters to all function signatures in BaseDecorator. This is not ideal and should be fixed! (In that case shield the variable keyword removal again for only the function in is_first_decorator.

Note that this adjustment has to happen after the __increase_count call in line 199:

self.__increase_count(id(self.func), id(execute))

Implement a StackDecorator

In many cases we might want to use a stacked variant of decorators. In that case we want to have a function like:

def stacked(*args):
  dec1 = ArgsHandler()
  dec2 = AuthHandler(...)
  # ...
  return StackDecorator([dec1, dec2, ...])


@stacked(...)
def main(req, ...):
  # ....

This should make it easier to use decorators across multiple functions (and make function code itself a bit clearer).

Most of the structure can probably be derived from Insights Decorator

Figure out Namespacing Support for Metrics

The MetricHandler in current state is a Singleton object. Meaning it will use one MeasurementMap for all metrics.
In most cases (esp in Azure Functions) this should not be a problem, since we only operate with one set of metrics at a time.

There might be edge cases though, where we want to have support for multiple MeasurementMaps? (Confirm that). If that is the case it would make sense to change the self._map module from a direct instance to a Dict[str, MeasurementMap] and create a default namespace.

If create_metrics is called with no namespace parameter this will use the default namespace, otherwise check if the namespace exists and if not create a new MeasurementMap.

This namespace parameter would then also need to be exposed to the Decorator. It might also require to create a thin wrapper object around MetricHandler (e.g. MetricNamespaceHandler or MetricNSHandler) to auto-pass the namespace for interactions with metrics inside the annotated function.

Bonus: We might also want to add a __namespace column automatically to all metrics and pass this information along in the TagMap.

Help Wanted

Please specify if this is a functionality that is really required!

Header Getter

Implement Getter to headers (such as ContentType) to make parsing easier.

Mock could be something like this:

from functown import RequestArgHandler, RequestHeaders as rh

args = RequestArgHandler(req)
value, meta = args.get_header(rh.ContentType)

Implement Serialization helper

The request currently supports json serialization.

Might add additional serializers that can be passed to RequestArgsHandler to retrieve body data.

Design for this still needs to be done but should support things like ProtoBuf (also look into overlap with RPC tools?)

Create an AuthDecorator

Right now authorization has to be done manually.

However, we could also create an auth decorator that handles this kind of authorization and passes the JWT object along.

Likely depends on the overhaul of the Decorator System #10

Increase Unit-Test Coverage for Insights Decorators

Due to dependency conflicts the test-coverage for the insights decorator is extremely low.

The goal would be to fix that. This requires to mock a bunch of functionality in opencensus.

It also requires to define a clearer structure for multiple view defined in parallel.

This will likely require changes in the metrics as well.

Note: Some of the unit tests already exists, but are flaky. Hence they are marked as pytest.mark.skip

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.