This repository was archived by the owner on Jul 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Assembly tagging #17
Open
daz10000
wants to merge
8
commits into
Amyris:master
Choose a base branch
from
demetrixbio:assembly_tagging
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Assembly tagging #17
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8926bbd
FEA: initial implementation of #tag support, doesn't pass serial tag…
7064042
FEA: support for TransientCumulative pragmas and multi line tagging
3bb8c2c
MIN: tidying up unused fucnction
377ef69
FEA: added tag field to flat file output
a570446
FEA: flat file format emits tags as TA lines
a376e99
DOC: basic markdown docs describing tagging feature
b77a32b
BUG: command line --tag arguments weren't getting folded in
158847d
Merge branch 'master' into assembly_tagging
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Tagging | ||
|
|
||
| Tags are terms within namespaces that can be associated with assemblies using the `tag` pragma. | ||
|
|
||
| ```GSL | ||
| // Example tag pragma, term red in the color namespace | ||
| #tag color:red | ||
| pTDH3>gERG10 | ||
| ``` | ||
|
|
||
| Tags are transient pragmas that associate with the next emitted assembly. Each tag consists of a namespace and term. More than one namespace pair can be specified with each `#tag`. | ||
|
|
||
| ```GSL | ||
| // Multiple tags for one assembly | ||
| #tag color:red flavor:vanilla | ||
| pTDH3>gERG10 | ||
| ``` | ||
|
|
||
| Multiple tags may be specified on different lines leading up to an assembly. Tags accumulate till an assembly is emitted. | ||
|
|
||
| ```GSL | ||
| #tag color:red | ||
| #tag flavor:vanilla | ||
| pTDH3>gERG10 | ||
| ``` | ||
|
|
||
| Tags may be emitted in various output formats. For example, the flatfile output emits tags using the `TA` line. | ||
|
|
||
| ``` | ||
| // GSL compiler version 0.4.32 | ||
| ##### Assembly 0 ####### | ||
| A# 0 | ||
| NA basic_delete | ||
| TA color:yellow id:123 | ||
| NP 7 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /// Assembly transforming plugin that implements seamless part assembly. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I not sure if a plugin is appropriate for implementing this feature. We had to extend the static type signature of assembly to accommodate this feature, so it seems to me like we should integrate the tagging addition directly into the assembly transformation stage. There is already a list of default assembly transformations that always happen and I think this is appropriate to add there. |
||
| module TaggingPlugin | ||
|
|
||
| open System | ||
| open LegacyParseTypes | ||
| open commonTypes | ||
| open commandConfig | ||
| open pragmaTypes | ||
| open PluginTypes | ||
| open Amyris.ErrorHandling | ||
|
|
||
| let taggingArg = | ||
| {name = "tag"; | ||
| param = ["namespace:value"]; | ||
| alias = []; | ||
| desc = "Add default tag to every assembly." | ||
| } | ||
|
|
||
| let parseTag (single:string) state = | ||
| match single.IndexOf(":") with | ||
| | -1 -> fail (sprintf "--tag value %s missing expected colon" single) | ||
| | colonPosition -> | ||
| ok ({ nameSpace=single.[..colonPosition-1].Trim() | ||
| tag=single.[colonPosition+1..].Trim() | ||
| }::state) | ||
|
|
||
| let parseTags (args:string list) = | ||
| args |> | ||
| List.fold ( | ||
| fun (state:Result<_,_>) (arg:string) -> | ||
| state >>= (parseTag arg) | ||
| ) (ok []) | ||
|
|
||
| /// do a trial parse and return ok unit if successful | ||
| let validateTag args = | ||
| parseTags args | ||
| >>= (fun _ -> ok ()) | ||
|
|
||
| let tagPragmaDef = | ||
| {name = "tag"; argShape = AtLeast 1; scope = BlockOnly(TransientCumulative); | ||
| desc = "tag assemblies with terms from a namespace."; | ||
| invertsTo = None; validate = validateTag} | ||
|
|
||
| /// Take previous #tag namespace:tagvalue lines and fold into the assembly structure | ||
| let foldInTags (cmdlineTags:AssemblyTag list) (_at:ATContext) (a:DnaAssembly) = | ||
| match a.pragmas.TryFind("tag") with | ||
| | None -> ok a | ||
| | Some pragma -> | ||
| match parseTags pragma.args with | ||
| | Ok(newTags,_) -> | ||
| ok {a with tags = cmdlineTags@newTags |> List.fold (fun tags tag -> tags.Add(tag)) a.tags} | ||
| | Bad msg -> fail {msg = String.Join(";",msg) ; kind = ATError ; assembly = a ; stackTrace = None ; fromException = None} | ||
|
|
||
| type TaggingProvider = { | ||
| cmdlineTags:AssemblyTag list | ||
| /// Optionally attach a function to this plugin behavior to permit its operation to be | ||
| /// configured by command line arguments injected by other plugins. This is necessary because | ||
| /// seamless assembly can alter a lot of expectations of downstream processing steps. | ||
| processExtraArgs: ParsedCmdLineArg -> TaggingProvider -> TaggingProvider} | ||
| with | ||
| interface IAssemblyTransform with | ||
| member __.ProvidedArgs() = [taggingArg] | ||
| member x.Configure(arg) = | ||
| if arg.spec = taggingArg then | ||
| match parseTags arg.values with | ||
| | Ok(v,_) -> | ||
| {x with cmdlineTags = v@x.cmdlineTags} | ||
| | Result.Bad messages -> | ||
| failwithf "%s" (String.Join("; ",messages)) | ||
|
|
||
| else x | ||
| |> x.processExtraArgs arg | ||
| :> IAssemblyTransform | ||
| member x.ConfigureFromOptions(_opts) = | ||
| x :> IAssemblyTransform | ||
| member x.TransformAssembly context assembly = | ||
| foldInTags x.cmdlineTags context assembly | ||
|
|
||
| /// Produce an instance of the seamless assembly plugin with the provided extra argument processor. | ||
| let createTaggingPlugin extraArgProcessor = | ||
| {name = "assembly tagging support" | ||
| description = Some "Allow tagging of assemblies with #tag namespace:tag" | ||
| behaviors = | ||
| [{name = None; | ||
| description = None; | ||
| behavior = AssemblyTransform({cmdlineTags = []; processExtraArgs = extraArgProcessor})}] | ||
| providesPragmas = [tagPragmaDef]; | ||
| providesCapas = []} | ||
|
|
||
| let taggingPlugin = createTaggingPlugin (fun _ x -> x) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned that this is now mixing two orthogonal concerns; whether or not a pragma is transient or not is orthogonal to whether or not a pragma should accumulate arguments when multiple instances of it appear.
Probably best thing to do here is refactor this to remove the additional variant from PragmaPersistence and add a field on PragmaDef, perhaps
accumulateArgs: bool. That should simplify the implementation of Add below.