Organizing analytics projects

Start with a single standalone project

Keep the organization's full analytical system in a single project and repository. This is simple to start with and keeps analytics easy to find and access. It can scale far, but may eventually need to be split into multiple projects.

Multiple independent projects

Full isolation

Keep multiple Uptimely projects fully independent. Each project owns its specification, build, and runtime configuration. In a monorepo, projects share a repository while remaining isolated. In a multirepo layout, each project has its own repository.

For a small number of projects, keeping them fully independent makes the setup simple.

Some amount of code repetition across independent projects is acceptable. When the organization grows, share reusable Python functions through packages.

Consolidating artifacts

In this approach builds from multiple independent projects are combined in deployment. If needed, the master project can combine build artifacts such as specs, plans or explorer data to a centralized database.

Each project can build and publish its own artifacts.

Alternatively, the deployment pipeline can build artifacts on behalf of projects that grant it repository access.

At the moment Uptimely does not provide tooling to consolidate multiple projects, so this part is user's responsibility.

Multiple dependent projects

Consider having foundational calculations that repeat in almost every data science project. For example: Whatever you calculate, you always need to first derive information about maintenance periods.

This needs to be done from data center pump measurements, because maintenance data is not integrated or is unreliable. The calculation logic varies by pump category, so you don't want to do this again in every project.

Pattern 1: Persist in between

The "trivial" approach is to create a standalone project for maintenance detection only. The results are materialized to storage that other projects can read the results from.

In most cases this by far easiest solution.

Even if this sounds simple, Uptimely profiles might be helpful abstraction to get calculations right. Also, the explorer gives everyone up-to-date view on the calculation logic and documentation out of the box. Pretty much all analytical use cases in the whole organization become dependent on these results, so the interface must be seamless.

One possible downside is time penalty from extra write and read to database compared to calculating in-memory. Depending on the setup, two separate processing pipelines might have delays in between.

Pattern 2: Reuse the build

What if a data scientist needs to tweak the logic on maintenance detection to get their neural networks right? Or what if they notice that something smells wrong in the maintenance detection and need to verify without being dependent on other project or team?

In this case it is not enough to have just the maintenance detection results, but reusable calculations are needed. Both the functions, but also their argument bindings. You don't want to spend a week writing hundreds of lines of Python or SQL just to get to filter maintenance events from the data.

If the maintenance detection was created by Uptimely, it could publish its build artifacts to shared file storage.

Any other person or team can access the full chain of analytical operators and run it as they wish.

Save the maintenance detection specification as spec/spec.yaml in the shared project. Keep the calculations in an importable Python module such as functions.py:

import polars as pl


def read_values() -> pl.DataFrame:
    return pl.DataFrame(
        {
            "id": [1, 2],
            "value": [10, 20],
        }
    )


def intermediate_step(dataset: pl.LazyFrame, output: str) -> pl.LazyFrame:
    random_value = pl.int_range(0, pl.len()).shuffle()
    return dataset.with_columns(random_value.alias(output))


def derive_maintenance(
    dataset: pl.LazyFrame,
    intermediate: str,
    output: str,
) -> pl.LazyFrame:
    return dataset.with_columns((pl.col(intermediate) > 0.5).alias(output))
name: Analytics Specification
dimensions:
  measurement_id:
    resolutions:
      measurement_id:
        key: id
        type: integer
profiles:
  telemetry:
    grain: [measurement_id.measurement_id]
    seed: read_values
    assembly:
      read_values:
        function: functions:read_values
        outputs: [value]
      intermediate_step:
        function: functions:intermediate_step
        args:
          dataset: "$profiles.@.dataset"
          output: "$output.intermediate_result"
      is_maintenance:
        function: functions:derive_maintenance
        args:
          dataset: "$profiles.@.dataset"
          intermediate: "$input.intermediate_result"
          output: "$output.is_maintenance"

The build artifacts are created from command line:

uptimely build

Then the files need to be published to accessible storage location.

The Python modules referenced by its spec must also be importable, for example through an installed package containing the shared implementation code.

Load the spec and remove both the is_maintenance operator and its feature declaration. Save the edited spec temporarily to spec.json, build it, and run its engine:

# example

import uptimely as up


spec = up.load_spec("shared-build/spec.json")
telemetry = spec.profiles["telemetry"]
del telemetry.assembly["is_maintenance"]
del telemetry.features["is_maintenance"]

updated_doc = "spec.json"
up.write_document(spec, updated_doc)

app = up.Uptimely()
bundle = app.build(updated_doc)
result = app.create_engine(bundle).run()

print(result.datasets["telemetry"])

The result contains id, value, and intermediate_result, without calculating is_maintenance. The shared spec stays unchanged.

Now the data scientist can use the intermediate results for their work.