Skip to content

Commit

Permalink
Improving widgets and other minor tweaks. (#7052)
Browse files Browse the repository at this point in the history
- Removed `module` argument from `enso_project` (new `Project_Description.new` API).
- Removed the custom option from date and time parse/format dropdowns.
- The `format` dropdown uses the value to create the dropdown. (Screenshot below)
- Removed `StorageType` coalescing rules and replaced them with simpler logic in `ObjectStorage`.
- Update signature for `add_row_number` and add aliases.
  • Loading branch information
jdunkerley authored Jun 19, 2023
1 parent 8b65509 commit 1859ccb
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 117 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
`Time_Period`.][6956]
- [Implemented `Table.update_database_table`.][7035]
- [Added AWS credential support and initial S3 list buckets API.][6973]
- [Removed `module` argument from `enso_project` and other minor tweaks.][7052]

[debug-shortcuts]:
https://github.com/enso-org/enso/blob/develop/app/gui/docs/product/shortcuts.md#debug
Expand Down Expand Up @@ -713,8 +714,9 @@
[6925]: https://github.com/enso-org/enso/pull/6925
[6941]: https://github.com/enso-org/enso/pull/6941
[6956]: https://github.com/enso-org/enso/pull/6956
[7035]: https://github.com/enso-org/enso/pull/7035
[6973]: https://github.com/enso-org/enso/pull/6973
[7035]: https://github.com/enso-org/enso/pull/7035
[7052]: https://github.com/enso-org/enso/pull/7052

#### Enso Compiler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ type Date
Format "2020-06-21" with French locale as "21. juin 2020"

example_format = Date.new 2020 6 21 . format "d. MMMM yyyy" (Locale.new "fr")
@pattern make_date_format_selector
@pattern (value-> make_date_format_selector value)
@locale Locale.default_widget
format : Text -> Locale -> Text
format self pattern:Text locale=Locale.default =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ type Date_Time

example_format =
Date_Time.parse "2020-06-21T16:41:13+03:00" . format "d. MMMM yyyy" (Locale.new "fr")
@pattern make_date_time_format_selector
@pattern (value-> make_date_time_format_selector value)
@locale Locale.default_widget
format : Text -> Locale -> Text
format self pattern:Text locale:Locale=Locale.default =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ type Time_Of_Day
from Standard.Base import Time_Of_Day

example_format = Time_Of_Day.new 16 21 10 . format "'hour:'h"
@pattern make_time_format_selector
@pattern (value-> make_time_format_selector value)
@locale Locale.default_widget
format : Text -> Locale -> Text
format self pattern:Text locale:Locale=Locale.default =
Expand Down
25 changes: 15 additions & 10 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import project.Function
import project.IO
import project.Math
import project.Meta
from project.Meta.Enso_Project import enso_project
import project.Meta.Enso_Project.Project_Description
import project.Nothing.Nothing
import project.Panic.Panic
import project.Polyglot.Java
Expand All @@ -33,6 +33,8 @@ import project.System.Process
import project.System.Process.Exit_Code.Exit_Code
import project.Warning.Warning

from project.Meta.Enso_Project import enso_project

export project.Any.Any
export project.Data.Array.Array
export project.Data.List.List
Expand All @@ -45,7 +47,7 @@ export project.Errors
export project.IO
export project.Math
export project.Meta
from project.Meta.Enso_Project export enso_project
export project.Meta.Enso_Project.Project_Description
export project.Nothing.Nothing
export project.Panic.Panic
export project.Polyglot.Java
Expand All @@ -67,14 +69,14 @@ export project.Warning.Warning
from project.Data.Boolean export Boolean, True, False
from project.Function export all
from project.Data.Numbers export Number, Integer, Decimal
from project.Meta.Enso_Project export enso_project
from project.System.File_Format export File_Format, Plain_Text_Format, Plain_Text, Bytes, Infer, Auto_Detect, JSON_Format

import project.Data
import project.Data.Filter_Condition.Filter_Condition
import project.Data.Index_Sub_Range.Index_Sub_Range
import project.Data.Interval.Bound
import project.Data.Interval.Interval
from project.Data.Json.Extensions import all
import project.Data.Json.Json
import project.Data.Json.JS_Object
import project.Data.Locale.Locale
Expand All @@ -87,13 +89,11 @@ import project.Data.Ordering.Default_Comparator
import project.Data.Sort_Direction.Sort_Direction
import project.Data.Pair.Pair
import project.Data.Range.Range
from project.Data.Range.Extensions import all
import project.Data.Regression
import project.Data.Statistics
import project.Data.Text.Case.Case
import project.Data.Text.Case_Sensitivity.Case_Sensitivity
import project.Data.Text.Encoding.Encoding
from project.Data.Text.Extensions import all
import project.Data.Text.Line_Ending_Style.Line_Ending_Style
import project.Data.Text.Location.Location
import project.Data.Text.Matching_Mode.Matching_Mode
Expand All @@ -112,7 +112,6 @@ import project.Data.Time.Time_Of_Day.Time_Of_Day
import project.Data.Time.Time_Period.Time_Period
import project.Data.Time.Time_Zone.Time_Zone
import project.Errors.Problem_Behavior.Problem_Behavior
from project.Network.Extensions import all
import project.Network.HTTP.Header.Header
import project.Network.HTTP.HTTP
import project.Network.HTTP.HTTP_Method.HTTP_Method
Expand All @@ -121,12 +120,16 @@ import project.Network.HTTP.HTTP_Version.HTTP_Version
import project.Network.URI.URI
import project.Random

from project.Data.Json.Extensions import all
from project.Data.Range.Extensions import all
from project.Data.Text.Extensions import all
from project.Network.Extensions import all

export project.Data
export project.Data.Filter_Condition.Filter_Condition
export project.Data.Index_Sub_Range.Index_Sub_Range
export project.Data.Interval.Bound
export project.Data.Interval.Interval
from project.Data.Json.Extensions export all
export project.Data.Json.Json
export project.Data.Json.JS_Object
export project.Data.Locale.Locale
Expand All @@ -137,13 +140,11 @@ export project.Data.Ordering.Comparable
export project.Data.Ordering.Default_Comparator
export project.Data.Pair.Pair
export project.Data.Range.Range
from project.Data.Range.Extensions export all
export project.Data.Regression
export project.Data.Sort_Direction.Sort_Direction
export project.Data.Text.Case.Case
export project.Data.Text.Case_Sensitivity.Case_Sensitivity
export project.Data.Text.Encoding.Encoding
from project.Data.Text.Extensions export all
export project.Data.Text.Line_Ending_Style.Line_Ending_Style
export project.Data.Text.Location.Location
export project.Data.Text.Matching_Mode.Matching_Mode
Expand All @@ -162,7 +163,6 @@ export project.Data.Time.Time_Of_Day.Time_Of_Day
export project.Data.Time.Time_Period.Time_Period
export project.Data.Time.Time_Zone.Time_Zone
export project.Errors.Problem_Behavior.Problem_Behavior
from project.Network.Extensions export all
export project.Network.HTTP.Header.Header
export project.Network.HTTP.HTTP
export project.Network.HTTP.HTTP_Method.HTTP_Method
Expand All @@ -171,6 +171,11 @@ export project.Network.HTTP.HTTP_Version.HTTP_Version
export project.Network.URI.URI
export project.Random

from project.Data.Json.Extensions export all
from project.Data.Range.Extensions export all
from project.Data.Text.Extensions export all
from project.Network.Extensions export all

from project.Data.Noise export all hiding Noise, Generator, Deterministic_Random, Long, Random
from project.Data.Statistics export all hiding to_moment_statistic, wrap_java_call, calculate_correlation_statistics, calculate_spearman_rank, calculate_correlation_statistics_matrix, compute_fold, empty_value, is_valid

Expand Down
60 changes: 36 additions & 24 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ from project.Errors.Common import Module_Not_In_Package_Error
## Functionality for inspecting the current project.
@Builtin_Type
type Project_Description
## Returns the Enso project description for the given module. If no module is
given, returns the description of the project that the engine was executed
with, i.e., the project that contains the `main` method, or throws
`Module_Not_In_Package_Error` if there is no such project, e.g., when
executing a single file.

Arguments:
- module: An optional module for which the Enso project description
will be fetched. If `Nothing`, the current project description will
be fetched.

> Example
Get the project description for the project that contains the `main`
method.

Project_Description.new

> Example
Get the project description for the `Standard.Visualizations` project.

Project_Description.new Standard.Visualizations

> Example
Get the project description for the `Standard.Base` project from the
`Vector` module.

Project_Description.new Standard.Base.Data.Vector
new : (Any | Nothing) -> Project_Description ! Module_Not_In_Package_Error
new module=Nothing = Project_Description.enso_project_builtin module

## PRIVATE
A representation of an Enso project.

Expand Down Expand Up @@ -52,33 +82,15 @@ type Project_Description
namespace : Text
namespace self = self.prim_config.namespace

## Returns the Enso project description for the given module. If no module is
given, returns the description of the project that the engine was executed
with, i.e., the project that contains the `main` method, or throws
`Module_Not_In_Package_Error` if there is no such project, e.g., when
executing a single file.

Arguments:
- module: An optional module for which the Enso project description
will be fetched. If `Nothing`, the current project description will
be fetched.
## Returns the Enso project description for the project that the engine was
executed with, i.e., the project that contains the `main` method, or
throws `Module_Not_In_Package_Error` if executing a single file.

> Example
Get the project description for the project that contains the `main`
method.

enso_project

> Example
Get the project description for the `Standard.Visualizations` project.

enso_project Standard.Visualizations

> Example
Get the project description for the `Standard.Base` project from the
`Vector` module.

enso_project Standard.Base.Data.Vector
enso_project : (Any | Nothing) -> Project_Description ! Module_Not_In_Package_Error
enso_project module=Nothing =
Project_Description.enso_project_builtin module
enso_project : Project_Description ! Module_Not_In_Package_Error
enso_project =
Project_Description.enso_project_builtin Nothing
37 changes: 13 additions & 24 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Widget_Helpers.enso
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,30 @@ make_delimiter_selector =

## PRIVATE
Creates a Single_Choice Widget for parsing dates.
make_date_format_selector : Widget
make_date_format_selector =
## Same Example Date as Excel
date = Date.new 2012 3 14

make_date_format_selector : Date -> Widget
make_date_format_selector (date:Date=(Date.new 2012 3 14)) =
iso_format = ['ISO-Format (e.g. ' + date.to_text + ')', '""']
formats = ['d/M/yyyy', 'dd/MM/yyyy', 'd-MMM-yy', 'd MMMM yyyy', 'M/d/yyyy', 'MM/dd/yyyy', 'MMMM d, yyyy'].map f-> [f + " (e.g. " + date.format f + ")", f.pretty]
custom_format = ['Custom', "'yyyy-MM-dd'"]

make_single_choice ([iso_format] + formats + [custom_format])
make_single_choice ([iso_format] + formats)

## PRIVATE
Creates a Single_Choice Widget for parsing date times.
make_date_time_format_selector : Widget
make_date_time_format_selector =
date = Date_Time.new 2012 3 14 15 9 26 123

enso_format = ['Default (e.g. ' + date.to_text + ')', '""']
iso_format = ['ISO-Format (e.g. ' + (date.format "ISO_ZONED_DATE_TIME") + ')', '"ISO_ZONED_DATE_TIME"']
iso_local = ['ISO-Local (e.g. ' + (date.format "ISO_LOCAL_DATE_TIME") + ')', '"ISO_LOCAL_DATE_TIME"']
make_date_time_format_selector : Date_Time -> Widget
make_date_time_format_selector (date_time:Date_Time=(Date_Time.new 2012 3 14 15 9 26 123)) =
enso_format = ['Default (e.g. ' + date_time.to_text + ')', '""']
iso_format = ['ISO-Format (e.g. ' + (date_time.format "ISO_ZONED_DATE_TIME") + ')', '"ISO_ZONED_DATE_TIME"']
iso_local = ['ISO-Local (e.g. ' + (date_time.format "ISO_LOCAL_DATE_TIME") + ')', '"ISO_LOCAL_DATE_TIME"']
formats = ['yyyy-MM-dd HH:mm:ss.S', 'yyyy-MM-dd HH:mm:ss.S VV', 'd/M/yyyy h:mm a', 'dd/MM/yyyy HH:mm:ss', 'd-MMM-yy HH:mm:ss', 'd-MMM-yy h:mm:ss a', 'd MMMM yyyy h:mm a', 'M/d/yyyy h:mm:ss a', 'MM/dd/yyyy HH:mm:ss']
mapped_formats = formats.map f-> [f + " (e.g. " + date.format f + ")", f.pretty]
custom_format = ['Custom', "'yyyy-MM-dd HH:mm:ss'"]
mapped_formats = formats.map f-> [f + " (e.g. " + date_time.format f + ")", f.pretty]

make_single_choice ([enso_format, iso_format, iso_local] + mapped_formats + [custom_format])
make_single_choice ([enso_format, iso_format, iso_local] + mapped_formats)

## PRIVATE
Creates a Single_Choice Widget for parsing times.
make_time_format_selector : Widget
make_time_format_selector =
## Same Example Time as Excel
time = Time_Of_Day.new 13 30 55 123

make_time_format_selector : Time_Of_Day -> Widget
make_time_format_selector (time:Time_Of_Day=(Time_Of_Day.new 13 30 55 123)) =
iso_format = ['ISO-Format (e.g. ' + time.to_text + ')', '""']
formats = ['HH:mm[:ss]', 'HH:mm:ss', 'h:mm[:ss] a', 'hh:mm:ss a', 'HH:mm:ss.S'].map f-> [f + " (e.g. " + time.format f + ")", f.pretty]
custom_format = ['Custom', "'HH:mm:ss'"]

make_single_choice ([iso_format] + formats + [custom_format])
make_single_choice ([iso_format] + formats)
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ type Table
msg = "`Table.drop` is not yet implemented."
Error.throw (Unsupported_Database_Operation.Error msg)

## Adds a new column to the table enumerating the rows.
## ALIAS rank, record id, add index column
Adds a new column to the table enumerating the rows.

Arguments:
- name: The name of the new column. Defaults to "Row".
Expand Down Expand Up @@ -562,7 +563,7 @@ type Table
problem is reported.
@group_by Widget_Helpers.make_column_name_vector_selector
@order_by Widget_Helpers.make_order_by_selector
add_row_number : Text -> Integer -> Integer -> Vector (Text | Integer | Column_Selector) | Text | Integer | Column_Selector -> Vector (Text | Sort_Column) | Text | Sort_Column -> Problem_Behavior -> Table
add_row_number : Text -> Integer -> Integer -> Vector (Text | Integer | Column_Selector) | Text | Integer -> Vector (Text | Sort_Column) | Text -> Problem_Behavior -> Table
add_row_number self name="Row" from=1 step=1 group_by=[] order_by=[] on_problems=Problem_Behavior.Report_Warning =
_ = [name, from, step, group_by, order_by, on_problems]
msg = "`Table.add_row_number` is not yet implemented in the Database backend."
Expand Down
5 changes: 3 additions & 2 deletions distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,8 @@ type Table
drop self range=(First 1) =
Index_Sub_Range_Module.drop_helper self.row_count self.rows.at self.slice (slice_ranges self) range

## Adds a new column to the table enumerating the rows.
## ALIAS rank, record id, add index column
Adds a new column to the table enumerating the rows.

Arguments:
- name: The name of the new column. Defaults to "Row".
Expand Down Expand Up @@ -1201,7 +1202,7 @@ type Table
problem is reported.
@group_by Widget_Helpers.make_column_name_vector_selector
@order_by Widget_Helpers.make_order_by_selector
add_row_number : Text -> Integer -> Integer -> Vector (Text | Integer | Column_Selector) | Text | Integer | Column_Selector -> Vector (Text | Sort_Column) | Text | Sort_Column -> Problem_Behavior -> Table
add_row_number : Text -> Integer -> Integer -> Vector (Text | Integer | Column_Selector) | Text | Integer -> Vector (Text | Sort_Column) | Text -> Problem_Behavior -> Table
add_row_number self name="Row" from=1 step=1 group_by=[] order_by=[] on_problems=Problem_Behavior.Report_Warning =
Add_Row_Number.add_row_number self name from step group_by order_by on_problems

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ type Id

example_id = Visualization.Id.from_module Base "My Visualization"
from_module module visualization_name =
Id.Library (enso_project module) visualization_name
Id.Library (Project_Description.new module) visualization_name
Original file line number Diff line number Diff line change
Expand Up @@ -1908,8 +1908,8 @@ class RuntimeErrorsTest
context.receiveNIgnorePendingExpressionUpdates(
3
) should contain theSameElementsAs Seq(
TestMessages.update(contextId, x1Id, ConstantsGen.NOTHING_BUILTIN),
TestMessages.update(contextId, mainRes1Id, ConstantsGen.NOTHING_BUILTIN),
TestMessages.update(contextId, x1Id, ConstantsGen.NOTHING),
TestMessages.update(contextId, mainRes1Id, ConstantsGen.NOTHING),
context.executionComplete(contextId)
)
context.consumeOut shouldEqual List("MyError")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ class EnsoProjectTest extends InterpreterTest {
val code =
"""
|from Standard.Base.Meta import enso_project
|from Standard.Base.Nothing import Nothing
|
|main = (enso_project Nothing).name
|main = enso_project.name
|""".stripMargin
eval(
code
Expand All @@ -26,9 +25,9 @@ class EnsoProjectTest extends InterpreterTest {
val code =
"""
|import Standard.Base
|from Standard.Base.Meta import enso_project
|from Standard.Base.Meta import Project_Description
|
|main = (enso_project Standard.Base).name
|main = (Project_Description.new Standard.Base).name
|""".stripMargin
eval(code) shouldEqual "Base"
}
Expand Down
14 changes: 8 additions & 6 deletions std-bits/aws/src/main/java/org/enso/aws/ProfileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
public class ProfileReader {
public static final ProfileReader INSTANCE = new ProfileReader();

private final String[] profiles;
private String[] profiles = null;

private ProfileReader() {
var provider = ProfileFileSupplier.defaultSupplier();
var profileFile = provider.get();
profiles = profileFile.profiles().keySet().toArray(new String[0]);
}
private ProfileReader() {}

public String[] getProfiles() {
if (profiles == null) {
var provider = ProfileFileSupplier.defaultSupplier();
var profileFile = provider.get();
profiles = profileFile.profiles().keySet().toArray(new String[0]);
}

return profiles;
}
}
Loading

0 comments on commit 1859ccb

Please sign in to comment.