Esempio n. 1
0
def gen_report_nested_blocks() -> dp.Report:
    return dp.Report(blocks=[
        dp.Blocks(
            dp.Markdown(
                text="# Test markdown block <hello/> \n Test **content**",
                id="test-id-1"),
            "Simple string Markdown",
        ),
        dp.Blocks(blocks=[
            dp.Markdown(
                text="# Test markdown block <hello/> \n Test **content**",
                id="test-id-2"),
            "Simple string Markdown",
        ]),
    ])
Esempio n. 2
0
def gen_report_with_files(datadir: Path,
                          single_file: bool = False) -> dp.Report:
    # Asset tests
    lis = [1, 2, 3]
    df = gen_df(10000)
    md_block = dp.Markdown(
        text="# Test markdown block <hello/> \n Test **content**")

    list_asset = dp.File(data=lis, name="List Asset", is_json=True)

    img_asset = dp.File(file=datadir / "datapane-logo.png")

    plot_asset = dp.Plot(data=alt.Chart(gen_df()).mark_line().encode(x="x",
                                                                     y="y"),
                         caption="Plot Asset")

    df_asset = dp.Table(df=df, caption="Test Dataframe Table")

    pivot_asset = dp.Table(df=df,
                           caption="Test Dataframe PivotTable",
                           can_pivot=True)

    if single_file:
        return dp.Report(dp.Blocks([md_block, plot_asset]))
    else:
        return dp.Report(list_asset, img_asset, df_asset, md_block, plot_asset,
                         pivot_asset)
Esempio n. 3
0
def gen_report_with_files(datadir: Path,
                          single_file: bool = False) -> dp.Report:
    # Asset tests
    lis = [1, 2, 3]
    small_df = gen_df()
    big_df = gen_df(10000)

    # text
    md_block = dp.Markdown(
        text="# Test markdown block </hello> \n Test **content**")
    html_block = dp.HTML(html="Hello World</hello>")
    big_number = dp.BigNumber(heading="Tests written", value=1234)
    big_number_1 = dp.BigNumber(heading="Real Tests written :)",
                                value=11,
                                change=2,
                                is_upward_change=True)

    # assets
    plot_asset = dp.Plot(data=alt.Chart(gen_df()).mark_line().encode(x="x",
                                                                     y="y"),
                         caption="Plot Asset")
    list_asset = dp.File(data=lis, name="List Asset", is_json=True)
    img_asset = dp.File(file=datadir / "datapane-logo.png")

    # tables
    table_asset = dp.Table(data=small_df, caption="Test Basic Table")
    dt_asset = dp.DataTable(df=big_df, caption="Test DataTable")
    dt_pivot_asset = dp.DataTable(df=big_df,
                                  caption="Test DataTable with Pivot",
                                  can_pivot=True)

    if single_file:
        return dp.Report(dp.Blocks(blocks=[md_block, plot_asset]))
    else:
        return dp.Report(
            md_block,
            html_block,
            big_number,
            big_number_1,
            plot_asset,
            list_asset,
            img_asset,
            table_asset,
            dt_asset,
            dt_pivot_asset,
        )
Esempio n. 4
0
    "NTAR.CN", "IDK.CN", "ART.V", "PKK.CN", "APHA.TO", "CMC.CN", "AMPD.CN",
    "MTRX.V"
]

curr_date = datetime.today().strftime('%Y-%m-%d')
start_date = (datetime.today() - timedelta(days=59)).strftime('%Y-%m-%d')

df_assets = generate_up(stock_list, start_date, curr_date)

figure_list = [
    dp.Plot(intraday_plot(stock, start_date, curr_date))
    for stock in stock_list
]

publish_report = False
dp_token = os.getenv('DP_TOKEN')
if dp_token:
    # login
    try:
        publish_report = True
    except Exception as e:
        print(e)

# login
r = dp.Report(f'### Intraday Report for {curr_date}', dp.Table(df_assets),
              dp.Blocks(*figure_list, columns=2))
r.save(path='index.html', open=True)

if publish_report == True:
    r.publish(name='Daily Report', open=False, tweet=False)