Airflow: configure datetime variables via the web app - airflow

Question
Is it possible to configure a datetime typed variable via the web app?
For example, If I want to change the value of the start_date variable.
I know how to configure string or numerical values through the web app. But just wondering whether I can do the same for datetime variables? I have had a look here at using macros. But didn't have any success. I have also tried adding raw string values, but that didn't work either
I am aware that I can define start_date as a string in my DAG file and then convert it to a datetime object within the file. That isn't what I'm asking
Please note that this question is specifically about setting the value of a datetime variable from the web app. I would also be interested in setting it from the cli. Anything that does not require a code change. Thanks

Related

How to declare a variable that persists subroutines

During the recv subroutine I am currently changing my backend to another backend to handle the request, I need to declare a variable that will hold the value for the first/original backend that it was set to, so that when the request is restarted, I can then assign the backend back to this.
I can't just use the name for the backend and simply assign it back as I need it to be dynamic, storing it in a variable seems like the simplest solution but I can't seem to find any information on how this can be achieved through subroutines/ restarts.
If not possible are there any other solutions I could try to achieve this? Probably not possible from what I understand but even the ability to access an array of the backends defined and picking the first one would suffice, I just cant rely on naming the backend to assign it back.
Unfortunately it isn't possible to declare a variable as a BACKEND type (which is what req.backend returns).
See this 'Fastly Fiddle' example that demonstrates you'll get a compiler error of:
Expected variable type, one of: BOOL, INTEGER, FLOAT, TIME, RTIME, IP or STRING
There also isn't any way to get a list of available backends via VCL either.
Additionally you would need to hardcode the backend value (i.e. you need to explicitly know what backends are defined from the VCL perspective) as trying to store a backend into a header or variable will convert it to a STRING type representation (such as 6kLtu7NicmMs0DtKsuite9--F_origin_0).
This means even if you were able to parse the actual F_origin_0 backend from the string you wouldn't be able to assign it as a value to req.backend as that expects the value to be of type BACKEND (and VCL doesn't provide a way, AFAIK, to convert a string into that type).

Symfony2 user timezone

I am building a symfony2 app where the user can choose her timezone. I made the neseccary model/form changes to store a timezone field in the User object.
To apply the timezone inside a specific controller action I can just use:
$user = $this->get('security.context')->getToken()->getUser();
date_default_timezone_set( $user->getTimezone() );
Is there a way to do this without having to modify every controller/action?
This is an old question but the same answer still applies.
date_default_timezone_set should not be used in this manner. If you create a Datetime instance, the timezone will always be set to symfonys default timezone. This will lead to inconsistencies, I wish you the best of luck finding them :)
Basically, you should create a custom DateTime type that handles conversion of timezones. Additionally, if you really want different timezone on your server, set the timezone in config/parameters.yml so php handles all dates in the timezone you need.
parameters:
default_timezone: Europe/Warsaw
There's a nice tutorial here that will show you everything you need to know.

BizTalk Business Rule Engine Compare DateTimeNow within a range of dates?

I try to use Between predicate to compare the current datetime with a range of date time.
I reference mscorlib assembly and use get_Now() within DateTime class in the assembly to get DateTimeNow. I have problem to compare this current datetime with the range.
my condition is like:
DateTimeNow is between 2012-08-03 07:00:00 and 2012-08-04 07:00:00
DateTimeNow at my region should be 2012-08-03 16:33:20 for this moment. It should between the range I specified. But it seems does not work. If I replace DateTimeNow with 2012-08-03 16:33:20, it works.
It seems for some reason my DateTimeNow does not work. Anyone has any idea?
I found to use Get_Date() function in .net mscorlib assembly, you have to modify your machine registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BusinessRules\3.0\StaticSupport (DWORD), give value 1
Details in:
http://blogs.msdn.com/b/richardbpi/archive/2005/11/14/492489.aspx
http://kinnaribhute.blogspot.co.nz/2008/04/some-interesting-stuff-about-biztalk.html
I am not sure how this will affect the production server, if the production server environment is not clustered with multiple node, there will be an outage for reboot the server.
There is an impedance mismatch between the way facts are logically modelled in the engine and the way objects are modelled in .NET code, and one effect of this is the problem of calling static methods. If you set the StaticSupport flag as described by Xiao Han, the engine changes its behaviour, treating static methods much as if they were built-in functions or predicates. By default, however, the engine treats static methods as behaviour of facts. Physically, a fact is an object in the working memory of the engine, and each fact has to be asserted to the engine before it's methods can be used. So, to call the static Now property getter on DateTime, you first have to assert a DateTime object to the engine. Of course, DateTime is a value type (structure), but that's OK because, when you execute a rule set, you assert a single fact as an Object or a collection of facts as an Object array. .NET will automatically box a DateTime (internally wrap it as an object) passed in this way.
It seems mad, I realise, having to assert an object to the engine in order to call a static method (or, in this case, a property getter, which is really a method, of course) on the type of that object. It would probably have been better if the engine had been built to treat static methods as built-ins by default. However, that was not the case. In addition, it would have been much better if Microsoft had implemented the StaticSupport flag at the level of individual rule sets, or even individual rules. Implementing it in the registry (machine-level), or alternatively configuring it in the .config file (application-level; use ) in this way can pose real problems because it can break rule sets that were written to use the opposite value of the flag.
Another point to bear in mind in that the Static Support can also be set to '2'. In this case, if you call a static method with no parameters, or if you call it with constant values only, and if you call it as a predicate in a condition or as an argument to another function, then the engine will evaluate the static member just once and cache the result.

TestNG testlistener - Possible to pass variables to retrieve in the ITestResult

I would like to be able to pass a variable a string variable to the ITestResult so that I can do something with it on a pass and failure.
I have a build number that is pulled off the screen and stored in a build variable. I then would like to be able to use this build variable after the test has passed or failed to report the results back to the database with this custom build text.
Does anyone know if this is possible?
You can use ITestContext#{s,g}etAttribute.

Setting CultureInfo in Tests project?

I've got an MVC app that I've set the globalization in the web.config. All is well in the web app. But in my tests project I'm getting an issue in my service layer. I'm asking for date of birth in the following format dd/MM/yyyy. I'm passing this as a string to my service layer. I've got a RegEx to check that it is formatted correctly but when it is and I try to convert it to a date I'm getting an error. This is because the CultureInfo is set to en.US, I want it to be en.GB. I've tried in one of my initialise test methods to do the following, to no avail:
string sCulture = ConfigurationSettings.AppSettings["CultureToUse"]; //returns "en.GB"
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(sCulture);
CultureInfo.CreateSpecificCulture(sCulture);
Any ideas how to set CultureInfo in my tests project?
Since you enforce the format that the data is in and it only is numeric, you shouldn't rely on a user defined setting and are better off using DateTime.ParseExact(dateString, "dd/MM/yyyy", CultureInfo.InvariantCulture).
The CurrentUICulture property controls the resources that get loaded for the app. CurrentCulture is what you want to set/get to control parsing/formatting.
ConfigurationSettings.AppSettings["CultureToUse"]
Must return "en-GB" not "en.GB", hope this helps!

Resources