Git Product home page Git Product logo

Comments (6)

doddsiedodds avatar doddsiedodds commented on June 15, 2024

For my understanding, what's the motivation for wanting to change this value? Reports with high number of elements getting id collisions?

from pybloqs.

DominikMChrist avatar DominikMChrist commented on June 15, 2024

Moving it into the user_config is trivial and would achieve the desired effect.

from pybloqs.

gityoav avatar gityoav commented on June 15, 2024

There are actually a few things about file savings which may be good for other but don't follow my use pattern.

The _id method is using uuid but this is uninformative to the user, I have changed it in my own branch to self._id = datetime.datetime.now().utcnow().strftime('%Y%m%d%H%M%S%f')
At this point ID_PRECISION does need to be set a little higher, but we do get meaningful sort on filename. Indeed, when I send an email, by knowing when the email was sent, I can then find the file and ''similar versions I didn't send but looked at'' in the temp dir really easily. Admittedly, sorting by date does the same thing, so I am perhaps just being silly, but it does make my life a little easier.

The other annoying thing is the save method... The tempdir is set in stone and cannot be overwritten.
tempdir = tempfile.gettempdir() #line 141 of block/base.py

Strangely, I would have thought both .show() and .save() and indeed .email() should really follow a similar pattern and write to similar locations. In my own usage pattern, all generate 'throw aways temp files' but what I like to do is to keep all the data in one place and then delete judiciously

Finally, and completely unrelated, the convenience Block method isn't quite as flexible as I need it, throwing exceptions e.g. for dicts or pd.Series. Here is my own, more convenient method :-)

def block(contents=None, title=None, title_level=3, title_wrap=False, inherit_cfg=True, **kwargs):
"""
Constructs a composable layout element that will be rendered automatically by
IPython Notebooks. It can also be saved in HTML, PDF, PNG or JPEG formats.
Content is handled as follows:
- Lists are written out into a grid layout, with a single column
- tuples are written out into a grid layout, with a single row
- DataFrames are written out as an interactive HTML table.
- Strings are written out in a raw format, preserving any HTML content in them.
- Nested blocks are simply wrapped, unless there is more than one in which case
the same logic applies as for lists, tuples and sets.
:param contents: Contents to put in a block.
:param title: Optional title of the block.
:param title_level: Optional title level (adjusts the size and TOC level), 1 being the
biggest and 9 being the smallest.
:param title_wrap: Toggles whitespace wrapping of the title. (Default: False).
:param inherit_cfg: Optional. Set to False to ensure that the block does not inherit
any parameters from parents.
:param cascade_cfg: Set to True to enable parmater cascading from this block. A value
of False means that child blocks do not inherit parameters from
this block.
:param kwargs: Optional styling arguments. The style keyword argument has special
meaning in that it allows styling to be grouped as one argument.
It is also useful in case a styling parameter name clashes with a standard
block parameter.
:return: A block instance.
"""
if isinstance(contents, pybloqs.BaseBlock):
return contents
elif isinstance(contents, list):
return pybloqs.block.layout.Grid([block(c) for c in contents],
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, tuple): # new but works like a treat...
return pybloqs.block.layout.HStack([block(c) for c in contents],
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, dict):
return pybloqs.block.layout.Grid([block(tuple(item)) for item in contents.items()],
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, pd.Series):
if len(contents)>0 and is_date(contents.index[0]):
return block(go.Scatter(x = contents.index, y = contents.values),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
else:
return block(dict(contents),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, Figure): #plotly figure
return pybloqs.block.image.PlotlyPlotBlock(contents,
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, BaseTraceHierarchyType): #like plotly.graph_objects.Scatter
return block(go.Figure(contents),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, pd.DataFrame):
if len(contents)>0 and is_date(contents.index[0]): #TimeSeries, not really a table
return pybloqs.block.image.PlotlyPlotBlock(df_to_fig(contents),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
else:
return pybloqs.block.table.HTMLJinjaTableBlock(contents,
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
elif isinstance(contents, Artist):
return pybloqs.block.image.PlotBlock(contents,
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)
else:
return Raw(str(contents),
title=title, title_level=title_level, title_wrap=title_wrap, inherit_cfg=inherit_cfg, **kwargs)

from pybloqs.

gityoav avatar gityoav commented on June 15, 2024

Dom, btw, why just pip and not conda? Doesn't this restrict target audience?

from pybloqs.

DominikMChrist avatar DominikMChrist commented on June 15, 2024

Added id_precision and tmp_dir to user_config as a drive-by of #68.

from pybloqs.

DominikMChrist avatar DominikMChrist commented on June 15, 2024

Re. conda: There was no demand for this yet. This would make a great contribution to the project as this is quite a standalone task.

from pybloqs.

Related Issues (20)

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.