Comments (6)
I have some observations:
- I see the same results when using
MaxDtdlVersion = 2
. I expected elements matching what is available in each version. - Instead of returning all implicit elements, we could split this in different methods, eg: by standard, instance and by extension.
- In the same way we added break out properties, will be good to provide a better object model to navigate these results, without forcing the "query+casting" pattern.
Could not find an easy way to answer original question: fetch all the units for Acceleration in #92
from dtdlparser.
- I see the same results when using
MaxDtdlVersion = 2
. I expected elements matching what is available in each version.
This seems to be an observation regarding the expectations of MaxDtdlVersion
. At present, the only effect of this option is to reject models that specify a DTDL context version exceeding this value. In other words, this comment does not relate only to the proposed GetImplicitElements() method but rather to the parser's full behavior in regard to the MaxDtdlVersion option. If you believe the parser should provide stronger semantics for this option, please open an issue to this effect. This is a highly non-trivial change.
- Instead of returning all implicit elements, we could split this in different methods, eg: by standard, instance and by extension.
Yes, this is possible. It would be similarly possible to split the extant GetSupplementalTypes() method into multiple methods that partition the types by extension. In the interest of parallelism between the types and the elements, it seems to me that either both methods should be split in this manner or neither should be. Implementing the split is significant additional work because the internal data structures do not at present partition the type and element information in this way.
- In the same way we added break out properties, will be good to provide a better object model to navigate these results, without forcing the "query+casting" pattern.
Are you referring to the casting to DTEnumValue in Tutorial13?
Could not find an easy way to answer original question: fetch all the units for Acceleration in #92
The additions to tutorials 12 and 13 illustrate how fetch all units for Distance (because this type was already used in the tutorial). The answer for Acceleration is a straightforward adaptation of the tutorial code.
from dtdlparser.
- I'll add a new issue wrt MaxDtdlVersion behavior
- Agreed, should be good to have the parallelism between types and elements.
- Tutorial 13 seems complicated to me, as it requires in-depth knowledge of the underlying DTDL concepts. I was thinking of a higher API that encapsulates how to access supplemental types and units. eg, to get all units for semantic types, I have to filter by EntityKind =Enum and then cast to DTEnumInfo
var implicitElements = new ModelParser().GetImplicitElements();
foreach (var implicitElement in implicitElements
.Where(i => i.Value.EntityKind == DTEntityKind.Enum && i.Value.Id.OriginalString.StartsWith("dtmi:dtdl:extension:quantitativeTypes"))
.Select(t => (DTEnumInfo)t.Value))
{
Console.WriteLine($"{ModelParser.GetTermOrUri(implicitElement.Id)} {implicitElement.Id}");
foreach (var item in implicitElement.EnumValues)
{
Console.WriteLine($" {item.Name}");
}
}
I would rather prefer something like:
var semanticTypes= new ModelParser().GetSemanticTypes();
foreach (var st in semanticTypes)
{
Console.WriteLine(st.Name);
foreach (var unit in st.Units)
{
Console.WriteLine($" {unit.Name}");
}
}
2 and 3 are very related and might lead to the same solution.
I would not use the implementation effort to drive the best API design.
from dtdlparser.
I did not mean to imply that I think we should avoid a good design because of the work it involves. I agree on the value of a easy-to-use solution.
- At present, there is no way whatsoever to access the unit information or any other non-type-level language or extension information via the parser API.
- At present, we have a method to access supplemental type information (which could be improved at some point to make it more usable), but we have no corresponding method for accessing model-level information.
We can queue up work to both (1) add a highly usable mechanism for accessing units and (2) improve the usability of the type-accessing mechanism, but I don't know either (a) how highly we should prioritize these relative to other work or (b) how quickly we could get these done once the work is started, since this are non-trivial efforts.
In view of the above, my inclination is to provide a mechanism now that (1) provides a perhaps non-ideal mechanism for accessing all model-level information from the metamodels via the parser, to enable use cases that are currently not enabled at all, and that (2) is parallel with the currently offered mechanism for accessing supplemental type information. If we do not do this, I expect it will be quite a while before these use cases are achievable.
from dtdlparser.
Ok, let's publish GetImplicitElements
Can we add a "manual wrapper" to implement GetSemanticTypes and Units?
from dtdlparser.
You mean like in a sample? The way we did with ParseToJson? This seems probably doable. I'll think on it a bit.
from dtdlparser.
Related Issues (20)
- Quirks for tolerating solecisms should not apply to DTDL v3 models
- DTDL v2 models should allow undefined extensions by default
- Enable existing DTDL V3 models with quantitative type extension to continue working HOT 1
- Add index.html to root of parser API docs page
- Flatten Model HOT 4
- ModelParser support for externally defined language extensions HOT 1
- Expand Max Depth of Model Inheritance HOT 1
- Feature proposal: provide inverse of DTInterfaceInfo/Extends property
- DTDLParser does not support .NET Framework projects
- Tutorials solution does not build on fresh clone
- Reorganize Solution, rename Parser.csproj, unify unit tests projects
- ModelParser does not sanity-check MaxDtdlVersion value
- MultiTarget to avoid BCL.AsyncInterfaces
- Add Support for Overriding Extension
- Review break out properties in typings HOT 4
- IndexOutOfRangeException when parsing models in multithreads HOT 6
- Parsing on multiple threads can lead to InvalidOperationException exceptions
- Fetch Units Information HOT 6
- ValidateInstance. Improve validation message for Enums HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dtdlparser.